java.lang.Object
jsonvalues.Key
- All Implemented Interfaces:
Comparable<Position>
,Position
Represents the key of a value in a JSON object
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionasIndex()
throws an UserError exception.asKey()
Returns this key.int
compares this key with another given position.boolean
Returns true if that is a key and both have the same name.int
hashCode()
Returns the hashcode of this key.boolean
isIndex()
Returns false.boolean
isKey()
Returns true.static Key
Returns a new instance which represents a key with the given name in a JSON object.toString()
Returns the name of the key.
-
Field Details
-
name
name of the key.
-
-
Method Details
-
of
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
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.- Specified by:
compareTo
in interfaceComparable<Position>
- Parameters:
o
- the given position- Returns:
- 0 if they are equal, +1 if this is greater, -1 otherwise
-
asKey
Returns this key. -
asIndex
throws an UserError exception. -
isIndex
public boolean isIndex()Returns false. -
isKey
public boolean isKey()Returns true. -
hashCode
public int hashCode()Returns the hashcode of this key. -
equals
Returns true if that is a key and both have the same name. -
toString
Returns the name of the key.
-