Class NitriteId

java.lang.Object
org.dizitart.no2.collection.NitriteId
All Implemented Interfaces:
Serializable, Comparable<NitriteId>

public final class NitriteId extends Object implements Comparable<NitriteId>, Serializable
A unique identifier across the Nitrite database. Each document in a nitrite collection is associated with a NitriteId.

During insertion if a unique object is supplied in the '_id' field of the document, then the value of the '_id' field will be used to create a new NitriteId. If the '_id' field is not supplied, then nitrite will generate a new [NitriteId] and will add it to the document.

Since:
1.0
Author:
Anindya Chatterjee
See Also:
  • Method Details

    • newId

      public static NitriteId newId()
      Creates a new auto-generated NitriteId.
      Returns:
      a new auto-generated NitriteId.
    • createId

      public static NitriteId createId(String value)
      Creates a NitriteId from a value.

      The value must be a string representation of a 64bit integer number.

      Parameters:
      value - the value
      Returns:
      the NitriteId
    • createId

      public static NitriteId createId(long value)
      Creates a NitriteId from a long value.
      Parameters:
      value - the value
      Returns:
      the NitriteId
    • validId

      public static boolean validId(Object value)
      Validates a value to be used as NitriteId.

      The value must be a string representation of a 64bit integer number.

      Parameters:
      value - the value
      Returns:
      `true` if the value is valid; otherwise `false`.
    • getIdValue

      public long getIdValue()
    • compareTo

      public int compareTo(NitriteId other)
      Specified by:
      compareTo in interface Comparable<NitriteId>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • get_idValue

      public long get_idValue()
      The underlying value of the NitriteId.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object