Package com.datastax.astra.client.model
Class ObjectId
java.lang.Object
com.datastax.astra.client.model.ObjectId
- All Implemented Interfaces:
Serializable,Comparable<ObjectId>
A globally unique identifier for objects.
Consists of 12 bytes, divided as follows:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| time | random value | inc | |||||||||
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionObjectId()Create a new object id.ObjectId(byte[] bytes) Constructs a new instance from the given byte arrayConstructs a new instance from a 24-byte hexadecimal string representation.ObjectId(ByteBuffer buffer) Constructs a new instance from the given ByteBufferConstructs a new instance using the given date. -
Method Summary
Modifier and TypeMethodDescriptionintbooleangetDate()Gets the timestamp as aDateinstance.inthashCode()voidputToByteBuffer(ByteBuffer buffer) Convert to bytes and put those bytes to the provided ByteBuffer.byte[]Convert to a byte array.Converts this instance into a 24-byte hexadecimal string representation.toString()
-
Constructor Details
-
ObjectId
public ObjectId()Create a new object id. -
ObjectId
Constructs a new instance using the given date.- Parameters:
date- the date
-
ObjectId
Constructs a new instance from a 24-byte hexadecimal string representation.- Parameters:
hexString- the string to convert- Throws:
IllegalArgumentException- if the string is not a valid hex string representation of an ObjectId
-
ObjectId
public ObjectId(byte[] bytes) Constructs a new instance from the given byte array- Parameters:
bytes- the byte array- Throws:
IllegalArgumentException- if array is null or not of length 12
-
ObjectId
Constructs a new instance from the given ByteBuffer- Parameters:
buffer- the ByteBuffer- Throws:
IllegalArgumentException- if the buffer is null or does not have at least 12 bytes remaining- Since:
- 3.4
-
-
Method Details
-
toByteArray
public byte[] toByteArray()Convert to a byte array. Note that the numbers are stored in big-endian order.- Returns:
- the byte array
-
putToByteBuffer
Convert to bytes and put those bytes to the provided ByteBuffer. Note that the numbers are stored in big-endian order.- Parameters:
buffer- the ByteBuffer- Throws:
IllegalArgumentException- if the buffer is null or does not have at least 12 bytes remaining- Since:
- 3.4
-
getDate
Gets the timestamp as aDateinstance.- Returns:
- the Date
-
toHexString
Converts this instance into a 24-byte hexadecimal string representation.- Returns:
- a string representation of the ObjectId in hexadecimal format
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<ObjectId>
-
toString
-