Class FeatureModelPersistenceManager
- All Implemented Interfaces:
AutoCloseable
changes to an IFeatureModel's backend.
The main goal of this class it to give more control over when changes are persisted. An important difference between the updater and the FeatureModelPersistenceManager is the frequency at which they are used, with the FeatureModelPersistenceManager typically being used less often. In other words:
- The
updatertypically only makes in-memory changes. These can occur in a high frequency and can be executed fast. - FeatureModelPersistenceManager can persist these in-memory changes. This is slower to execute, can require more resources (disk access for example), but can be performed at a lower frequency.
For example: when dragging a point from one location to another in an editor configured to update on any change, many small updates are done along the way. In contrast, a save typically only happens when the editing is finished.
A FeatureModelPersistenceManager can be accessed through the model using IFeatureModel#getPersistenceManager.
See this article for more information.
- Since:
- 2023.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classIFeatureModelimplementations that have support forsaving changescan use this class to create a FeatureModelPersistenceManager instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidDiscards the unsaved (in-memory) changes of theIFeatureModel, restoring theIFeatureModel'sstate back to that of its backend.booleanprotected voidfinalize()List<@NotNull FeatureChange> Returns the list of all unsaved (in-memory) changes if theIFeatureModel.inthashCode()Returns a newFeatureModelPersistenceManagerbuilder.Save thein-memory changesin theIFeatureModel's backend (for example a file or database).
-
Method Details
-
finalize
protected void finalize() -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
newBuilder
Returns a newFeatureModelPersistenceManagerbuilder.- Returns:
- a new
FeatureModelPersistenceManagerbuilder.
-
saveChanges
Save thein-memory changesin theIFeatureModel's backend (for example a file or database).Typically, calling this method shouldn't modify the in-memory state of the model. So the feature model will not send out events through its
observers. In some cases however (depending on the model implementation), feature changes can occur while changes are saved. In that case, the model's observers need to be notified of those changes.- Returns:
nullon success, or error information on failure.
-
discardChanges
public void discardChanges()Discards the unsaved (in-memory) changes of theIFeatureModel, restoring theIFeatureModel'sstate back to that of its backend.All
observerswill be notified with aFeatureModelEventcontaining theFeatureChangesnecessary to go back to the backend's state. -
getChanges
Returns the list of all unsaved (in-memory) changes if theIFeatureModel.That is, the changes that need to be saved to the
IFeatureModel'sbackend to persist all in-memory changes. Multiple updates to the same feature will be condensed to a singleFeatureChange.- Returns:
- the list of all unsaved (in-memory) changes if the
IFeatureModel.
-
hashCode
public int hashCode() -
equals
-