|
|||||||||
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(java.lang.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. |
java.lang.String |
getNameWithIds()
Returns the name with ids as suffix enclosed inside '[', ']' brackets. |
java.lang.String |
getToken()
Returns an underlying String identifier (might be useful when storing human-readable names). |
int |
hashCode()
|
java.lang.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 java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String getToken()
getToken
in interface IToken
public long[] getIds()
getIds
in interface IToken
public java.lang.String getNameWithIds()
public java.lang.String toString()
getNameWithIds()
.
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |