Package com.foxinmy.weixin4j.util
Class ObjectId
- java.lang.Object
-
- com.foxinmy.weixin4j.util.ObjectId
-
- All Implemented Interfaces:
Serializable
,Comparable<ObjectId>
public class ObjectId extends Object implements Comparable<ObjectId>, Serializable
A globally unique identifier for objects.
Consists of 12 bytes, divided as follows:
ObjectID layout 0 1 2 3 4 5 6 7 8 9 10 11 time machine pid inc Instances of this class are immutable.
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(ObjectId id)
boolean
equals(Object o)
static ObjectId
get()
Gets a new object id.static int
getCurrentCounter()
Gets the current value of the auto-incrementing counter.Date
getDate()
Gets the timestamp as aDate
instance.int
getTimestamp()
Gets the timestamp (number of seconds since the Unix epoch).int
hashCode()
static boolean
isValid(String s)
Checks if a string could be anObjectId
.byte[]
toByteArray()
Convert to a byte array.String
toHexString()
Converts this instance into a 24-byte hexadecimal string representation.String
toString()
-
-
-
Method Detail
-
get
public static ObjectId get()
Gets a new object id.- Returns:
- the new id
-
isValid
public static boolean isValid(String s)
Checks if a string could be anObjectId
.- Parameters:
s
- a potential ObjectId as a String.- Returns:
- whether the string could be an object id
- Throws:
IllegalArgumentException
- if hexString is null
-
toHexString
public String toHexString()
Converts this instance into a 24-byte hexadecimal string representation.- Returns:
- a string representation of the ObjectId in hexadecimal format
-
toByteArray
public byte[] toByteArray()
Convert to a byte array. Note that the numbers are stored in big-endian order.- Returns:
- the byte array
-
compareTo
public int compareTo(ObjectId id)
- Specified by:
compareTo
in interfaceComparable<ObjectId>
-
getTimestamp
public int getTimestamp()
Gets the timestamp (number of seconds since the Unix epoch).- Returns:
- the timestamp
-
getDate
public Date getDate()
Gets the timestamp as aDate
instance.- Returns:
- the Date
-
getCurrentCounter
public static int getCurrentCounter()
Gets the current value of the auto-incrementing counter.- Returns:
- the current counter value.
-
-