org.nasdanika.persistence.Persistent Maven / Gradle / Ivy
package org.nasdanika.persistence;
/**
* Something which knows how to store state into storage and load it from it.
* @author Pavel Vlasov
*
* @param Referenced object type.
* @param Reference type.
* @param Storage type.
*/
public interface Persistent {
/**
* Loads state from the storage.
* @param storage Storage.
* @param resolver Reference resolver. Can be ``null`` if the object itself "knows" how to resolve references,
* e.g. it utilizes object proxies resolved on access.
*/
void load(S storage, Resolver resolver);
/**
* Same as load(storage, null).
* @param storage
*/
default void load(S storage) {
load(storage, null);
}
/**
* Stores state into the storage.
* @param storage
*/
void store(S storage, Referencer referencer);
/**
* Same as store(storage, null).
* @param storage
*/
default void store(S storage) {
store(storage, null);
}
}