Package jsonvalues
Class Key
- java.lang.Object
-
- jsonvalues.Key
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IndexasIndex()throws an UserError exception.KeyasKey()Returns this key.intcompareTo(Position o)compares this key with another given position.booleanequals(java.lang.Object that)Returns true if that is a key and both have the same name.inthashCode()Returns the hashcode of this key.booleanisIndex()Returns false.booleanisKey()Returns true.static Keyof(java.lang.String key)Returns a new instance which represents a key with the given name in a json object.java.lang.StringtoString()Returns the name of the key.
-
-
-
Method Detail
-
of
public static Key of(java.lang.String key)
Returns a new instance which represents a key with the given name in a json object. Any string, but null, can represent a key in a json object, even the empty string.- Parameters:
key- the given name of the key- Returns:
- a new Key object
-
compareTo
public int compareTo(Position o)
compares this key with another given position. If the given position is a key, both are compared lexicographically, if it's an index, both are compared numerically.
-
asKey
public Key asKey()
Returns this key.
-
asIndex
public Index asIndex()
throws an UserError exception.
-
isIndex
public boolean isIndex()
Returns false.
-
hashCode
public int hashCode()
Returns the hashcode of this key.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hashcode of the name.
-
equals
public boolean equals(java.lang.Object that)
Returns true if that is a key and both have the same name.- Overrides:
equalsin classjava.lang.Object- Parameters:
that- other object- Returns:
- true if both object are Keys with the same name
-
toString
public java.lang.String toString()
Returns the name of the key.- Overrides:
toStringin classjava.lang.Object- Returns:
- the name of the key
-
-