public class SnapshotRepository
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.util.List<SnapshotDateParser> |
dateParsers |
protected java.io.File |
dir |
Constructor and Description |
---|
SnapshotRepository(java.io.File dir)
Create a new instance of a repository.
|
SnapshotRepository(java.lang.String dir)
Create a new instance of a repository.
|
Modifier and Type | Method and Description |
---|---|
protected void |
detectDate(Snapshot snapshot)
Attempt to detect a snapshot's date and assign it.
|
Snapshot |
getDefaultSnapshot(java.lang.String world)
Get the default snapshot.
|
java.io.File |
getDirectory()
Get the snapshot directory.
|
Snapshot |
getSnapshot(java.lang.String name)
Get a snapshot.
|
Snapshot |
getSnapshotAfter(java.time.ZonedDateTime date,
java.lang.String world)
Get the first snapshot after a date.
|
Snapshot |
getSnapshotBefore(java.time.ZonedDateTime date,
java.lang.String world)
Get the first snapshot before a date.
|
java.util.List<Snapshot> |
getSnapshots(boolean newestFirst,
java.lang.String worldName)
Get a list of snapshots in a directory.
|
protected boolean |
isValidSnapshot(java.io.File file)
Check to see if a snapshot is valid.
|
boolean |
isValidSnapshotName(java.lang.String snapshot)
Check to see if a snapshot is valid.
|
protected java.io.File dir
protected java.util.List<SnapshotDateParser> dateParsers
public SnapshotRepository(java.io.File dir)
dir
- the directorypublic SnapshotRepository(java.lang.String dir)
dir
- the directorypublic java.util.List<Snapshot> getSnapshots(boolean newestFirst, java.lang.String worldName) throws MissingWorldException
newestFirst
- true to get the newest firstMissingWorldException
@Nullable public Snapshot getSnapshotAfter(java.time.ZonedDateTime date, java.lang.String world) throws MissingWorldException
date
- a dateMissingWorldException
@Nullable public Snapshot getSnapshotBefore(java.time.ZonedDateTime date, java.lang.String world) throws MissingWorldException
date
- a dateMissingWorldException
protected void detectDate(Snapshot snapshot)
snapshot
- the snapshot@Nullable public Snapshot getDefaultSnapshot(java.lang.String world) throws MissingWorldException
world
- the world nameMissingWorldException
public boolean isValidSnapshotName(java.lang.String snapshot)
snapshot
- a snapshot nameprotected boolean isValidSnapshot(java.io.File file)
file
- the file to the snapshotpublic Snapshot getSnapshot(java.lang.String name) throws InvalidSnapshotException
name
- the name of the snapshotInvalidSnapshotException
- if the snapshot is invalidpublic java.io.File getDirectory()