T
- the type of object serialized into the filepublic class FileBackedObject<T extends Serializable> extends Object implements PersistenceBackedObject<T>
Constructor and Description |
---|
FileBackedObject(Class<T> clazz)
Constructs an empty FileBackedObject.
|
FileBackedObject(Class<T> clazz,
File backingFile)
Constructs a FileBackedObject using an existing File object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
exists()
Returns whether the intended persistence location is already populated.
|
String |
getPath()
Returns the path to the intended persistence location.
|
T |
newInstance(TreeLogger logger)
Constructs and returns a new instance of the object stored at the path.
|
void |
set(TreeLogger logger,
T object)
Serializes the provided object to the intended path.
|
String |
toString() |
public FileBackedObject(Class<T> clazz) throws IOException
clazz
- the type of object to be serializedIOException
- if the temporary file could not be createdpublic boolean exists()
PersistenceBackedObject
exists
in interface PersistenceBackedObject<T extends Serializable>
public String getPath()
PersistenceBackedObject
getPath
in interface PersistenceBackedObject<T extends Serializable>
public T newInstance(TreeLogger logger) throws UnableToCompleteException
PersistenceBackedObject
newInstance
in interface PersistenceBackedObject<T extends Serializable>
UnableToCompleteException
- if the backing store does not contain an object of type
T
public void set(TreeLogger logger, T object) throws IllegalStateException, UnableToCompleteException
PersistenceBackedObject
set
in interface PersistenceBackedObject<T extends Serializable>
UnableToCompleteException
- if the object could not be serializedIllegalStateException
Copyright © 2018. All rights reserved.