Class VersionedHolder<T>

java.lang.Object
com.simsilica.lemur.core.VersionedHolder<T>
All Implemented Interfaces:
VersionedObject<T>

public class VersionedHolder<T> extends Object implements 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 Details

    • VersionedHolder

      public VersionedHolder()
    • VersionedHolder

      public VersionedHolder(T initialValue)
  • Method Details

    • getVersion

      public long getVersion()
      Description copied from interface: VersionedObject
      Returns the current version of the versioned object.
      Specified by:
      getVersion in interface VersionedObject<T>
    • setObject

      public void setObject(T value)
      Sets a new value to the refenced object and increments the version.
    • updateObject

      public boolean updateObject(T value)
      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

      public T getObject()
      Description copied from interface: VersionedObject
      Returns the object that is being versioned.
      Specified by:
      getObject in interface VersionedObject<T>
    • createReference

      public VersionedReference<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 interface VersionedObject<T>