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
-
Constructor Summary
ConstructorDescriptionObjId
(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 TypeMethodDescriptionlong
asLong()
Get this instance encoded as along
value.int
boolean
getBytes()
Get the binary encoding of this instance.static KeyRange
getKeyRange
(int storageId) Get theKeyRange
containing all object IDs with the given storage ID.static ObjId
getMax
(int storageId) Get the largest (i.e., last) instance having the given storage ID.static ObjId
getMin
(int storageId) Get the smallest (i.e., first) instance having the given storage ID.int
Get the storage ID associated with this instance.int
hashCode()
Returns the hash code value for this instance.toString()
Encode this instance as a string.void
writeTo
(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
- ifstorageId
is zero or negative
-
ObjId
Constructor that parses a string previously returned bytoString()
.- Parameters:
string
- string encoding of an instance- Throws:
IllegalArgumentException
- ifstring
is invalid
-
ObjId
Constructor that reads an encoded instance from the givenByteData.Reader
.- Parameters:
reader
- input for binary encoding of an instance- Throws:
IllegalArgumentException
- ifreader
contains invalid data
-
ObjId
public ObjId(long value) Constructor using a long value previously returned byasLong()
.- Parameters:
value
- long encoding of an instance- Throws:
IllegalArgumentException
- ifvalue
is 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 along
value.- 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
- ifstorageId
is 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
- ifstorageId
is zero or negative
-
getKeyRange
Get theKeyRange
containing all object IDs with the given storage ID.- Parameters:
storageId
- storage ID, must be greater than zero- Returns:
KeyRange
containing all object IDs having the specified type- Throws:
IllegalArgumentException
- ifstorageId
is zero or negative
-
toString
Encode this instance as a string. -
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<ObjId>
-