Class SnapshotFile


  • @API(status=EXPERIMENTAL)
    public final class SnapshotFile
    extends java.lang.Object
    A snapshot file is a plain text file containing a header and the actual serialized snapshot. The header is a simple key-value format which is separated from the actual snapshot contents by two line breaks (\n). Snapshot files are always encoded in UTF-8.

    You can use this class to manually read the contents of a persisted snapshot file.

    This class is immutable and only holds the file's contents. It is not a reference to the actually stored file.

    Since:
    0.0.5
    See Also:
    SnapshotTestResult
    • Method Detail

      • fromSnapshotFile

        public static SnapshotFile fromSnapshotFile​(java.nio.file.Path file)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • readFrom

        public static SnapshotFile readFrom​(java.io.BufferedReader reader)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • header

        public SnapshotFile.SnapshotHeader header()
        Header information to this snapshot that are written by the framework.
        Returns:
        The header.
      • snapshot

        public java.lang.String snapshot()
        The serialized snapshot. This is the string that has been produced by the SnapshotSerializer in place.
        Returns:
        The serialized snapshot string.
      • writeTo

        public SnapshotFile writeTo​(java.nio.file.Path snapshotFile)
                             throws java.io.IOException
        Writes this object to the specified file, potentially overriding it if it already exists.
        Parameters:
        snapshotFile - The target file to write to.
        Returns:
        The instance.
        Throws:
        java.io.IOException - If an IO error occurs during writing.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object