|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.amis.utils.token.Token
public class Token
Represents a String that can be used inside Map
as keys or Set
s as
equals(Object)
has O(1) time complexity which is much better when
compared to the O(N) time complexity of String.equals(Object)
.
Note that you can't instantiate this token, instead use Tokens.get(long)
or Tokens.get(String)
which is THREAD-SAFE.
The object is suitable for serialization / deserialization, even sending the object between
JVM won't broke anything as it has Token#readObject()
implemented the way that
ensures that two same name
won't receive different ids
.
Method Summary | |
---|---|
boolean |
equals(Object obj)
Actually the implementation is as good as it can be, containing early-success checking + NPE-proofed. |
long[] |
getIds()
Returns unique ID of the token. |
String |
getNameWithIds()
Returns the name with ids as suffix enclosed inside '[', ']' brackets. |
String |
getToken()
Returns an underlying String identifier (might be useful when storing human-readable names). |
int |
hashCode()
|
String |
toString()
Returns getNameWithIds() . |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public String getToken()
getToken
in interface IToken
public long[] getIds()
getIds
in interface IToken
public String getNameWithIds()
public String toString()
getNameWithIds()
.
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |