Package io.permazen.core
Class ObjId
java.lang.Object
io.permazen.core.ObjId
- All Implemented Interfaces:
Serializable,Comparable<ObjId>
Object IDs. Instances identify individual
Database objects.- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionObjId(int storageId) Create a new, random instance with the given storage ID.ObjId(long value) Constructor using a long value previously returned byasLong().ObjId(ByteData.Reader reader) Constructor that reads an encoded instance from the givenByteData.Reader.Constructor that parses a string previously returned bytoString(). -
Method Summary
Modifier and TypeMethodDescriptionlongasLong()Get this instance encoded as alongvalue.intbooleangetBytes()Get the binary encoding of this instance.static KeyRangegetKeyRange(int storageId) Get theKeyRangecontaining all object IDs with the given storage ID.static ObjIdgetMax(int storageId) Get the largest (i.e., last) instance having the given storage ID.static ObjIdgetMin(int storageId) Get the smallest (i.e., first) instance having the given storage ID.intGet the storage ID associated with this instance.inthashCode()Returns the hash code value for this instance.toString()Encode this instance as a string.voidwriteTo(ByteData.Writer writer) Write the binary encoding of this instance to the given output.
-
Field Details
-
Constructor Details
-
ObjId
public ObjId(int storageId) Create a new, random instance with the given storage ID.- Parameters:
storageId- storage ID, must be greater than zero- Throws:
IllegalArgumentException- ifstorageIdis zero or negative
-
ObjId
Constructor that parses a string previously returned bytoString().- Parameters:
string- string encoding of an instance- Throws:
IllegalArgumentException- ifstringis invalid
-
ObjId
Constructor that reads an encoded instance from the givenByteData.Reader.- Parameters:
reader- input for binary encoding of an instance- Throws:
IllegalArgumentException- ifreadercontains invalid data
-
ObjId
public ObjId(long value) Constructor using a long value previously returned byasLong().- Parameters:
value- long encoding of an instance- Throws:
IllegalArgumentException- ifvalueis invalid
-
-
Method Details
-
getStorageId
public int getStorageId()Get the storage ID associated with this instance. This is the storage ID of the associated object type.- Returns:
- object type storage ID
-
getBytes
Get the binary encoding of this instance.- Returns:
- binary encoding
-
asLong
public long asLong()Get this instance encoded as alongvalue.- Returns:
- long encoding
-
writeTo
Write the binary encoding of this instance to the given output.- Parameters:
writer- destination
-
getMin
Get the smallest (i.e., first) instance having the given storage ID.- Parameters:
storageId- storage ID, must be greater than zero- Returns:
- smallest instance with storage ID
storageId(inclusive) - Throws:
IllegalArgumentException- ifstorageIdis zero or negative
-
getMax
Get the largest (i.e., last) instance having the given storage ID.- Parameters:
storageId- storage ID, must be greater than zero- Returns:
- largest instance with storage ID
storageId(inclusive) - Throws:
IllegalArgumentException- ifstorageIdis zero or negative
-
getKeyRange
Get theKeyRangecontaining all object IDs with the given storage ID.- Parameters:
storageId- storage ID, must be greater than zero- Returns:
KeyRangecontaining all object IDs having the specified type- Throws:
IllegalArgumentException- ifstorageIdis zero or negative
-
toString
Encode this instance as a string. -
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<ObjId>
-