Package com.thecoderscorner.menu.persist
Class PropertiesMenuStateSerialiser
java.lang.Object
com.thecoderscorner.menu.persist.PropertiesMenuStateSerialiser
- All Implemented Interfaces:
MenuStateSerialiser
An implementation of menu state serialization that stores data in a properties file at a given location.
var tree = new MenuTree();
var propStore = new PropertiesMenuStateSerialiser(tree, Path.of("./props.properties"));
propStore.loadMenuStatesAndApply();
// Some time later...
propStore.saveMenuStates();
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionload the menu states but do not apply them to the treevoidload back all states from the storage and apply them all to the tree, after this all items in the tree will contain the updated value.voidSave the latest state of the tree into storage.
-
Constructor Details
-
Method Details
-
loadMenuStatesAndApply
public void loadMenuStatesAndApply()Description copied from interface:MenuStateSerialiserload back all states from the storage and apply them all to the tree, after this all items in the tree will contain the updated value.- Specified by:
loadMenuStatesAndApplyin interfaceMenuStateSerialiser
-
loadMenuStates
Description copied from interface:MenuStateSerialiserload the menu states but do not apply them to the tree- Specified by:
loadMenuStatesin interfaceMenuStateSerialiser- Returns:
- the list of states loaded from storage
-
saveMenuStates
public void saveMenuStates()Description copied from interface:MenuStateSerialiserSave the latest state of the tree into storage.- Specified by:
saveMenuStatesin interfaceMenuStateSerialiser
-