- java.lang.Object
-
- de.skuzzle.test.snapshots.SnapshotFile
-
@API(status=EXPERIMENTAL) public final class SnapshotFile extends 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).This class is immutable.
- Since:
- 0.0.5
- Author:
- Simon Taddiken
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSnapshotFile.SnapshotHeader
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SnapshotFilechangeHeader(SnapshotFile.SnapshotHeader newHeader)Creates a newSnapshotFileinstance with the given header and the same snapshot contents.booleanequals(Object obj)static SnapshotFilefromSnapshotFile(Path file)inthashCode()SnapshotFile.SnapshotHeaderheader()Header information to this snapshot that are written by the framework.static SnapshotFileof(SnapshotFile.SnapshotHeader header, String snapshot)static SnapshotFilereadFrom(BufferedReader reader)Stringsnapshot()The serialized snapshot.SnapshotFilewriteTo(Path snapshotFile)Writes this object to the specified file, potentially overriding it if it already exists.
-
-
-
Method Detail
-
of
public static SnapshotFile of(SnapshotFile.SnapshotHeader header, String snapshot)
-
fromSnapshotFile
public static SnapshotFile fromSnapshotFile(Path file) throws IOException
- Throws:
IOException
-
readFrom
public static SnapshotFile readFrom(BufferedReader reader) throws IOException
- Throws:
IOException
-
changeHeader
@API(status=EXPERIMENTAL, since="1.2.1") public SnapshotFile changeHeader(SnapshotFile.SnapshotHeader newHeader)Creates a newSnapshotFileinstance with the given header and the same snapshot contents.- Parameters:
newHeader- The new header.- Returns:
- A new
SnapshotFileinstance. - Since:
- 1.2.1
-
header
public SnapshotFile.SnapshotHeader header()
Header information to this snapshot that are written by the framework.- Returns:
- The header.
-
snapshot
public String snapshot()
The serialized snapshot. This is the string that has been produced by theSnapshotSerializerin place.- Returns:
- The serialized snapshot string.
-
writeTo
public SnapshotFile writeTo(Path snapshotFile) throws 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:
IOException- If an IO error occurs during writing.
-
-