Class VersionedObject<K,V>

java.lang.Object
org.rostore.client.VersionedObject<K,V>
Type Parameters:
K - key object type
V - value object type

public class VersionedObject<K,V> extends Object
Versioned object, containing the object itself, and metadata: ttl information and version
  • Method Details

    • createEternal

      public static <K, V> VersionedObject<K,V> createEternal(K key, V object, Long version)
      Creates an eternal versioned object
      Type Parameters:
      K - type of the key
      V - type of the value
      Parameters:
      key - the key object
      object - the value object
      version - the version of the entry
      Returns:
      entity
    • createUnversionedEternal

      public static <K, V> VersionedObject<K,V> createUnversionedEternal(K key, V value)
      Creates an eternal unversioned object
      Type Parameters:
      K - type of the key
      V - type of the value
      Parameters:
      key - the key object
      value - the value object
      Returns:
      entity
    • createNewVersionedEternal

      public static <K, V> VersionedObject<K,V> createNewVersionedEternal(K key, V value)
      Creates first version of eternal object
      Type Parameters:
      K - type of the key
      V - type of the value
      Parameters:
      key - the key object
      value - the value object
      Returns:
      entity
    • createNewVersioned

      public static <K, V> VersionedObject<K,V> createNewVersioned(K key, V value, Long unixEol)
      Creates first version of the entity with the expiration timestamp
      Type Parameters:
      K - type of the key
      V - type of the value
      Parameters:
      key - the key object
      value - the value object
      unixEol - the unix epoch's end of entity's life
      Returns:
      entity
    • create

      public static <K, V> VersionedObject<K,V> create(K key, V value, Long version, Long unixEol)
      Creates a versioned object (general case)
      Type Parameters:
      K - type of the key
      V - type of the value
      Parameters:
      key - the key object
      value - the value object
      version - the version of the entry
      unixEol - the unix epoch's end of entity's life
      Returns:
      entity
    • createDeserialized

      public static <K, V1, V2> VersionedObject<K,V2> createDeserialized(VersionedObject<K,V1> original, V2 value)
    • getUnixEOL

      public long getUnixEOL()
      Returns:
      0 if object is eternal, otherwise millisecond counter when to expire
    • getKey

      public K getKey()
      Returns the key's object
      Returns:
      the key
    • getObjectClass

      public Class<V> getObjectClass()
      Get the Class of the object
      Returns:
      object's class
    • getVersion

      public Long getVersion()
      Get the object's version.

      If unversioned returns Utils.VERSION_UNDEFINED

      Returns:
    • isVersioned

      public boolean isVersioned()
      Gets is the object versioned or not
      Returns:
      true if the object versioned, false otherwise
    • getValue

      public V getValue()
      Get the value
      Returns:
      the object
    • toString

      public String toString()
      Overrides:
      toString in class Object