public class Token extends Object implements IToken, Serializable
Map as keys or Sets 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.
| Modifier and Type | Method and Description |
|---|---|
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(). |
public boolean equals(Object obj)
public String getToken()
public long[] getIds()
public String getNameWithIds()
public String toString()
getNameWithIds().Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.