Package com.simsilica.lemur.core
Class VersionedHolder<T>
java.lang.Object
com.simsilica.lemur.core.VersionedHolder<T>
- All Implemented Interfaces:
VersionedObject<T>
A utility implementation of a simple VersionedObject wrapper
object. This provides easy support for a VersionedObject especially
in cases where a referring class will have several separately
versioned values.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a new VersionedReference that can be used to monitor when this object changes.Returns the object that is being versioned.long
Returns the current version of the versioned object.void
Manually increments the version causing VersionedReferences to see this object as changed.void
Sets a new value to the refenced object and increments the version.boolean
updateObject
(T value) Sets a new value to the refenced object only if has changed.
-
Constructor Details
-
VersionedHolder
public VersionedHolder() -
VersionedHolder
-
-
Method Details
-
getVersion
public long getVersion()Description copied from interface:VersionedObject
Returns the current version of the versioned object.- Specified by:
getVersion
in interfaceVersionedObject<T>
-
setObject
Sets a new value to the refenced object and increments the version. -
updateObject
Sets a new value to the refenced object only if has changed. An value is considered changed if oldValue != newValue and oldValue.equals(newValue) returns false. Returns true if the object was actually changed. -
incrementVersion
public void incrementVersion()Manually increments the version causing VersionedReferences to see this object as changed. This is useful in cases where it is known that the object's fields have changed in some way the VersionedReference holders might care about. -
getObject
Description copied from interface:VersionedObject
Returns the object that is being versioned.- Specified by:
getObject
in interfaceVersionedObject<T>
-
createReference
Description copied from interface:VersionedObject
Creates a new VersionedReference that can be used to monitor when this object changes.- Specified by:
createReference
in interfaceVersionedObject<T>
-