public class Id extends Object implements Comparable<Id>
Node or a Commit.
This implementation aims at minimizing the in-memory footprint
of an identifier instance. therefore it doesn't cache e.g. the hashCode
or the string representation.
Important Note:
An Id is considered immutable. The byte[]
passed to Id(byte[]) must not be reused or modified, the same
applies for the byte[] returned by getBytes().| Constructor and Description |
|---|
Id(byte[] raw)
Creates a new instance based on the passed
byte[]. |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Id o) |
boolean |
equals(Object obj) |
static Id |
fromLong(long value)
Creates an
Id instance from a long. |
static Id |
fromString(String s)
Creates an
Id instance from its
string representation as returned by toString(). |
byte[] |
getBytes()
Returns the raw byte representation of this identifier.
|
int |
hashCode() |
String |
toString() |
public Id(byte[] raw)
byte[].
The passed byte[] mus not be reused, it's assumed
to be owned by the new Id instance.raw - the byte representationpublic static Id fromString(String s)
Id instance from its
string representation as returned by toString().
The following condition holds true:
Id someId = ...; assert(Id.fromString(someId.toString()).equals(someId));
s - a string representation of an IdId instanceIllegalArgumentException - if s is not a valid string representationpublic static Id fromLong(long value)
Id instance from a long.value - a longId instancepublic int compareTo(Id o)
compareTo in interface Comparable<Id>public byte[] getBytes()
byte[] MUST NOT be modified!Copyright © 2012-2013 The Apache Software Foundation. All Rights Reserved.