Class MapNode

java.lang.Object
uk.blankaspect.common.basictree.AbstractNode
uk.blankaspect.common.basictree.MapNode
All Implemented Interfaces:
Cloneable, ITreeNode<AbstractNode>

public class MapNode extends AbstractNode
This class implements a node that contains a collection of key–value pairs whose keys are strings and whose values are nodes. In the documentation of this class, key–value pair is sometimes abbreviated to KV pair or just pair.

A map node preserves the order of the key–value pairs that are added to it; that is, an iterator over the collection of KV pairs will traverse the pairs in the order in which their keys were added to the map node. (The same is true of iterators over the collections of keys (getKeys()) or values (getChildren()).) If a KV pair is added to a map node that already contains a KV pair whose key is equal to the key of the new pair, the value of the new pair will replace the old value in the map without affecting the order of the KV pairs.

A map node may be created with an initial collection of key–value pairs. A map node is mutable: KV pairs may be added to and removed from a map node after its creation.

The default string representation of a map node begins with a '{' (U+007B) and ends with a '}' (U+007D). The key of a KV pair is escaped and enclosed in quotation marks in the same way as the value of a string node. The key and value of a KV pair are separated with a ':' (U+003A). Adjacent KV pairs are separated with a ',' (U+002C).

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    This class encapsulates a key–value pair of a map node.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char
    The character that denotes the end of the string representation of a map node.
    static final char
    The character that separates the key and value of a KV pair in the string representation of a map node.
    static final char
    The character that separates adjacent KV pairs in the string representation of a map node.
    static final char
    The character that denotes the start of the string representation of a map node.
    static final NodeType
    The type of a map node.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of a map node that has no parent and initially contains no key–value pairs.
    MapNode(Iterable<? extends MapNode.Pair> pairs)
    Creates a new instance of a map node that has no parent and initially contains the specified key–value pairs.
    Creates a new instance of a map node that has no parent and initially contains the specified key–value pairs.
    Creates a new instance of a map node that has the specified parent and initially contains no key–value pairs.
    MapNode(AbstractNode parent, Iterable<? extends MapNode.Pair> pairs)
    Creates a new instance of a map node that has the specified parent and initially contains the specified key–value pairs.
    Creates a new instance of a map node that has the specified parent and initially contains the specified key–value pairs.
    MapNode(AbstractNode parent, MapNode.Pair... pairs)
    Creates a new instance of a map node that has the specified parent and initially contains the specified key–value pairs.
    Creates a new instance of a map node that has no parent and initially contains the specified key–value pairs.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(String key, AbstractNode value)
    Adds a key–value pair with the specified key and value to this map node.
    void
    Adds the specified key–value pair to this map node.
    addBoolean(String key, boolean value)
    Creates a new instance of a Boolean node, adds it to this map node as a key–value pair with the specified key and returns it.
    addBooleans(String key, boolean... values)
    Creates a new instance of a list node whose elements are new instances of Boolean nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it.
    Creates a new instance of a list node whose elements are new instances of Boolean nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it.
    addDouble(String key, double value)
    Creates a new instance of a 'double' node, adds it to this map node as a key–value pair with the specified key and returns it.
    addDoubles(String key, double... values)
    Creates a new instance of a list node whose elements are new instances of 'double' nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it.
    Creates a new instance of a list node whose elements are new instances of 'double' nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it.
    <T extends AbstractNode>
    T
    addIfAbsent(String key, T value)
    Adds a key–value pair with the specified key and value to this map node if it does not already contain a KV pair with the specified key.
    addInt(String key, int value)
    Creates a new instance of an 'int' node, adds it to this map node as a key–value pair with the specified key and returns it.
    addInts(String key, int... values)
    Creates a new instance of a list node whose elements are new instances of 'int' nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it.
    addInts(String key, Iterable<Integer> values)
    Creates a new instance of a list node whose elements are new instances of 'int' nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it.
    addList(String key, Iterable<? extends AbstractNode> elements)
    Creates a new instance of a list node that contains the specified elements, adds it to this map node as a key–value pair with the specified key and returns it.
    addList(String key, AbstractNode... elements)
    Creates a new instance of a list node that contains the specified elements, adds it to this map node as a key–value pair with the specified key and returns it.
    addLong(String key, long value)
    Creates a new instance of a 'long' node, adds it to this map node as a key–value pair with the specified key and returns it.
    addLongs(String key, long... values)
    Creates a new instance of a list node whose elements are new instances of 'long' nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it.
    addLongs(String key, Iterable<Long> values)
    Creates a new instance of a list node whose elements are new instances of 'long' nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it.
    addMap(String key, Iterable<? extends MapNode.Pair> pairs)
    Creates a new instance of a map node that contains the specified pairs of keys and values, adds the new map node to this map node as a key–value pair with the specified key and returns it.
    Creates a new instance of a map node that contains the specified pairs of keys and values, adds the new map node to this map node as a key–value pair with the specified key and returns it.
    addMap(String key, MapNode.Pair... pairs)
    Creates a new instance of a map node that contains the specified pairs of keys and values, adds the new map node to this map node as a key–value pair with the specified key and returns it.
    Creates a new instance of a null node, adds it to this map node as a key–value pair with the specified key and returns it.
    void
    addPairs(Iterable<? extends MapNode.Pair> pairs)
    Adds the specified key–value pairs to the key–value pairs of this map node.
    void
    Adds the specified pairs of keys and values to the key–value pairs of this map node.
    void
    Adds the specified key–value pairs to the key–value pairs of this map node.
    addString(String key, String value)
    Creates a new instance of a string node, adds it to this map node as a key–value pair with the specified key and returns it.
    Creates a new instance of a list node whose elements are new instances of string nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it.
    addStrings(String key, String... values)
    Creates a new instance of a list node whose elements are new instances of string nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it.
    void
    Removes all the key–value pairs of this map node.
    Creates and returns a deep copy of this map node that has no parent.
    boolean
    Returns true if the specified object is an instance of MapNode and this map node contains the same number of key–value pairs as the other map node and for each KV pair in this map node, kv1, there is a KV pair in the other map node, kv2, for which the keys of kv1 and kv2 are equal and the values of kv1 and kv2 are equal.
    Returns the key that is associated with the specified value in this map node.
    get(String key)
    Returns the value of the key–value pair of this map node with the specified key.
    boolean
    Returns the underlying value of the Boolean node that is associated with the specified key in this map node.
    boolean
    getBoolean(String key, boolean defaultValue)
    Returns the underlying value of the Boolean node that is associated with the specified key in this map node.
    Returns the Boolean node that is associated with the specified key in this map node.
    Returns a list of the values of the key–value pairs of this map node.
    double
    Returns the underlying value of the 'double' node that is associated with the specified key in this map node.
    double
    getDouble(String key, double defaultValue)
    Returns the underlying value of the 'double' node that is associated with the specified key in this map node.
    Returns the 'double' node that is associated with the specified key in this map node.
    <E extends Enum<E>>
    E
    getEnumValue(Class<E> cls, String key, E defaultValue)
    Returns the constant of the specified enumeration type whose name matches the underlying value of the string node that is associated with the specified key in this map node.
    <E extends Enum<E>>
    E
    getEnumValue(Class<E> cls, String key, Function<E,String> converter, E defaultValue)
    Returns the constant of the specified enumeration type that, after the specified converter has been applied to it, matches the underlying value of the string node that is associated with the specified key in this map node.
    int
    Returns the underlying value of the 'int' node that is associated with the specified key in this map node.
    int
    getInt(String key, int defaultValue)
    Returns the underlying value of the 'int' node that is associated with the specified key in this map node.
    Returns the 'int' node that is associated with the specified key in this map node.
    long
    Returns the underlying value of the 'int' node or 'long' node that is associated with the specified key in this map node.
    long
    getIntOrLong(String key, long defaultValue)
    Returns the underlying value of the 'int' node or 'long' node that is associated with the specified key in this map node.
    Returns a list of the keys of the key–value pairs of this map node.
    Returns the list node that is associated with the specified key in this map node.
    long
    Returns the underlying value of the 'long' node that is associated with the specified key in this map node.
    long
    getLong(String key, long defaultValue)
    Returns the underlying value of the 'long' node that is associated with the specified key in this map node.
    Returns the 'long' node that is associated with the specified key in this map node.
    Returns the map node that is associated with the specified key in this map node.
    Returns the null node that is associated with the specified key in this map node.
    int
    Returns the number of key–value pairs that this map node contains.
    Returns an iterator over the key–value pairs of this map node.
    Returns a list of the key–value pairs of this map node.
    Returns an unmodifiable map of the key–value pairs of this map node.
    Returns the underlying value of the string node that is associated with the specified key in this map node.
    getString(String key, String defaultValue)
    Returns the underlying value of the string node that is associated with the specified key in this map node.
    Returns the string node that is associated with the specified key in this map node.
    Returns the type of this node.
    boolean
    Returns true if this map node contains a key–value pair whose key is the specified key and whose value is a Boolean node.
    boolean
    Returns true if this map node contains a key–value pair whose key is the specified key and whose value is a 'double' node.
    int
    Returns the hash code of this map node, which is the hash code of its key–value pairs.
    boolean
    Returns true if this map node contains a key–value pair whose key is the specified key and whose value is an 'int' node.
    boolean
    Returns true if this map node contains a key–value pair whose key is the specified key and whose value is either an 'int' node or a 'long' node.
    boolean
    Returns true if this map node contains a key–value pair with the specified key.
    boolean
    Returns true if this map node contains a key–value pair whose key is the specified key and whose value is a list node.
    boolean
    Returns true if this map node contains a key–value pair whose key is the specified key and whose value is a 'long' node.
    boolean
    Returns true if this map node contains a key–value pair whose key is the specified key and whose value is a map node.
    boolean
    Returns true if this map node contains a key–value pair whose key is the specified key and whose value is a null node.
    boolean
    Returns true if this map node contains a key–value pair whose key is the specified key and whose value is a string node.
    boolean
    Returns true if this node can contain other nodes.
    boolean
    Returns true if this map node contains no key–value pairs.
    static String
    Returns a string representation of the specified key for a map node.
    static String
    keyToString(CharSequence key, boolean printableAsciiOnly)
    Returns a string representation of the specified key for a map node.
    pair(String key, boolean value)
    Creates a Boolean node for the specified value, creates a key–value pair whose key is the specified key and whose value is the Boolean node, and returns the KV pair.
    pair(String key, double value)
    Creates a 'double' node for the specified value, creates a key–value pair whose key is the specified key and whose value is the 'double' node, and returns the KV pair.
    pair(String key, int value)
    Creates an 'int' node for the specified value, creates a key–value pair whose key is the specified key and whose value is the 'int' node, and returns the KV pair.
    pair(String key, long value)
    Creates a 'long' node for the specified value, creates a key–value pair whose key is the specified key and whose value is the 'long' node, and returns the KV pair.
    pair(String key, String value)
    Creates a string node for the specified value, creates a key–value pair whose key is the specified key and whose value is the string node, and returns the KV pair.
    void
    Removes the key–value pairs with the specified keys from this map node.
    void
    remove(String... keys)
    Removes the key–value pairs with the specified keys from this map node.
    void
    remove(Predicate<String> keyFilter)
    Removes from this map node the key–value pairs whose keys are accepted by the specified filter.
    void
    retain(String... keys)
    Removes all key–value pairs from this map node except for those with the specified keys.
    void
    Removes all key–value pairs from this map node except for those with the specified keys.
    void
    retain(Predicate<String> keyFilter)
    Removes all key–value pairs from this map node except for those whose keys are accepted by the specified filter.
    void
    Sets the key–value pairs of this map node to the specified pairs of keys and values.
    void
    Sorts the key–value pairs of this map node into ascending order of their keys by applying the String.compareTo(String) method to the keys.
    void
    sort(Comparator<String> keyComparator)
    Sorts the key–value pairs of this map node by applying the specified comparator to their keys.
    Returns a string representation of this map node.
    toString(boolean printableAsciiOnly)
    Returns a string representation of this node whose characters may optionally be escaped where necessary so that the returned string contains only printable characters from the US-ASCII character encoding.

    Methods inherited from class uk.blankaspect.common.basictree.AbstractNode

    getListIndex, getMapKey, getParent, isRoot, setParent

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface uk.blankaspect.common.tree.ITreeNode

    isLeaf
  • Field Details

    • START_CHAR

      public static final char START_CHAR
      The character that denotes the start of the string representation of a map node.
      See Also:
    • END_CHAR

      public static final char END_CHAR
      The character that denotes the end of the string representation of a map node.
      See Also:
    • KEY_VALUE_SEPARATOR_CHAR

      public static final char KEY_VALUE_SEPARATOR_CHAR
      The character that separates the key and value of a KV pair in the string representation of a map node.
      See Also:
    • PAIR_SEPARATOR_CHAR

      public static final char PAIR_SEPARATOR_CHAR
      The character that separates adjacent KV pairs in the string representation of a map node.
      See Also:
    • TYPE

      public static final NodeType TYPE
      The type of a map node.
  • Constructor Details

    • MapNode

      public MapNode()
      Creates a new instance of a map node that has no parent and initially contains no key–value pairs.
    • MapNode

      public MapNode(AbstractNode parent)
      Creates a new instance of a map node that has the specified parent and initially contains no key–value pairs.
      Parameters:
      parent - the parent of the map node.
    • MapNode

      public MapNode(MapNode.Pair... pairs)
      Creates a new instance of a map node that has no parent and initially contains the specified key–value pairs.
      Parameters:
      pairs - the initial key–value pairs of the map node.
    • MapNode

      public MapNode(Iterable<? extends MapNode.Pair> pairs)
      Creates a new instance of a map node that has no parent and initially contains the specified key–value pairs.
      Parameters:
      pairs - the initial key–value pairs of the map node.
    • MapNode

      public MapNode(Map<String,AbstractNode> pairs)
      Creates a new instance of a map node that has no parent and initially contains the specified key–value pairs.
      Parameters:
      pairs - the initial key–value pairs of the map node.
    • MapNode

      public MapNode(AbstractNode parent, MapNode.Pair... pairs)
      Creates a new instance of a map node that has the specified parent and initially contains the specified key–value pairs.
      Parameters:
      parent - the parent of the map node.
      pairs - the initial key–value pairs of the map node.
    • MapNode

      public MapNode(AbstractNode parent, Iterable<? extends MapNode.Pair> pairs)
      Creates a new instance of a map node that has the specified parent and initially contains the specified key–value pairs.
      Parameters:
      parent - the parent of the map node.
      pairs - the initial key–value pairs of the map node.
    • MapNode

      public MapNode(AbstractNode parent, Map<String,AbstractNode> pairs)
      Creates a new instance of a map node that has the specified parent and initially contains the specified key–value pairs.
      Parameters:
      parent - the parent of the map node.
      pairs - the initial key–value pairs of the map node.
  • Method Details

    • pair

      public static MapNode.Pair pair(String key, boolean value)
      Creates a Boolean node for the specified value, creates a key–value pair whose key is the specified key and whose value is the Boolean node, and returns the KV pair.
      Parameters:
      key - the key of the key–value pair.
      value - the value of the Boolean node.
      Returns:
      a key–value pair whose key is key and whose value is a new Boolean node whose value is value.
    • pair

      public static MapNode.Pair pair(String key, int value)
      Creates an 'int' node for the specified value, creates a key–value pair whose key is the specified key and whose value is the 'int' node, and returns the KV pair.
      Parameters:
      key - the key of the key–value pair.
      value - the value of the 'int' node.
      Returns:
      a key–value pair whose key is key and whose value is a new 'int' node whose value is value.
    • pair

      public static MapNode.Pair pair(String key, long value)
      Creates a 'long' node for the specified value, creates a key–value pair whose key is the specified key and whose value is the 'long' node, and returns the KV pair.
      Parameters:
      key - the key of the key–value pair.
      value - the value of the 'long' node.
      Returns:
      a key–value pair whose key is key and whose value is a new 'long' node whose value is value.
    • pair

      public static MapNode.Pair pair(String key, double value)
      Creates a 'double' node for the specified value, creates a key–value pair whose key is the specified key and whose value is the 'double' node, and returns the KV pair.
      Parameters:
      key - the key of the key–value pair.
      value - the value of the 'double' node.
      Returns:
      a key–value pair whose key is key and whose value is a new 'double' node whose value is value.
    • pair

      public static MapNode.Pair pair(String key, String value)
      Creates a string node for the specified value, creates a key–value pair whose key is the specified key and whose value is the string node, and returns the KV pair.
      Parameters:
      key - the key of the key–value pair.
      value - the value of the string node.
      Returns:
      a key–value pair whose key is key and whose value is a new string node whose value is value.
    • keyToString

      public static String keyToString(CharSequence key)
      Returns a string representation of the specified key for a map node.
      Parameters:
      key - the key whose string representation is desired.
      Returns:
      the string representation of key.
    • keyToString

      public static String keyToString(CharSequence key, boolean printableAsciiOnly)
      Returns a string representation of the specified key for a map node.
      Parameters:
      key - the key whose string representation is desired.
      printableAsciiOnly - if true, the characters of key will be escaped where necessary so that the returned string contains only printable characters from the US-ASCII character encoding (ie, characters in the range U+0020 to U+007E inclusive).
      Returns:
      the string representation of key.
    • getType

      public NodeType getType()
      Description copied from class: AbstractNode
      Returns the type of this node.
      Specified by:
      getType in class AbstractNode
      Returns:
      TYPE.
    • isContainer

      public boolean isContainer()
      Returns true if this node can contain other nodes. For a map node, this method always returns true.
      Specified by:
      isContainer in class AbstractNode
      Returns:
      true.
    • getChildren

      public List<AbstractNode> getChildren()
      Returns a list of the values of the key–value pairs of this map node. The list may be modified without affecting this map node, but modifying the elements of the list (for example, changing the parent of a node) will affect this map node.
      Specified by:
      getChildren in interface ITreeNode<AbstractNode>
      Overrides:
      getChildren in class AbstractNode
      Returns:
      a list of the values of the key–value pairs of this map node.
      See Also:
    • equals

      public boolean equals(Object obj)
      Returns true if the specified object is an instance of MapNode and this map node contains the same number of key–value pairs as the other map node and for each KV pair in this map node, kv1, there is a KV pair in the other map node, kv2, for which the keys of kv1 and kv2 are equal and the values of kv1 and kv2 are equal.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object with which this map node will be compared.
      Returns:
      true if obj is an instance of MapNode and this map node contains the same number of key–value pairs as the other map node and for each KV pair in this map node, kv1, there is a KV pair in the other map node, kv2, for which the keys of kv1 and kv2 are equal and the values of kv1 and kv2 are equal; false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash code of this map node, which is the hash code of its key–value pairs.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code of this map node.
    • clone

      public MapNode clone()
      Creates and returns a deep copy of this map node that has no parent.
      Overrides:
      clone in class AbstractNode
      Returns:
      a deep copy of this map node that has no parent.
    • toString

      public String toString()
      Returns a string representation of this map node.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this map node.
    • toString

      public String toString(boolean printableAsciiOnly)
      Returns a string representation of this node whose characters may optionally be escaped where necessary so that the returned string contains only printable characters from the US-ASCII character encoding.
      Overrides:
      toString in class AbstractNode
      Parameters:
      printableAsciiOnly - if true, the characters of the string representation will be escaped where necessary so that the returned string contains only printable characters from the US-ASCII character encoding (ie, characters in the range U+0020 to U+007E inclusive).
      Returns:
      a string representation of this node.
    • isEmpty

      public boolean isEmpty()
      Returns true if this map node contains no key–value pairs.
      Returns:
      true if this map node contains no key–value pairs; false otherwise.
    • getNumPairs

      public int getNumPairs()
      Returns the number of key–value pairs that this map node contains.
      Returns:
      the number of key–value pairs that this map node contains.
    • hasKey

      public boolean hasKey(String key)
      Returns true if this map node contains a key–value pair with the specified key.
      Parameters:
      key - the key of the key–value pair of interest.
      Returns:
      true if this map node contains a key–value pair whose key is key; false otherwise.
    • hasNull

      public boolean hasNull(String key)
      Returns true if this map node contains a key–value pair whose key is the specified key and whose value is a null node.
      Parameters:
      key - the key of the key–value pair of interest.
      Returns:
      true if this map node contains a key–value pair whose key is key and whose value is a null node; false otherwise.
    • hasBoolean

      public boolean hasBoolean(String key)
      Returns true if this map node contains a key–value pair whose key is the specified key and whose value is a Boolean node.
      Parameters:
      key - the key of the key–value pair of interest.
      Returns:
      true if this map node contains a key–value pair whose key is key and whose value is a Boolean node; false otherwise.
    • hasInt

      public boolean hasInt(String key)
      Returns true if this map node contains a key–value pair whose key is the specified key and whose value is an 'int' node.
      Parameters:
      key - the key of the key–value pair of interest.
      Returns:
      true if this map node contains a key–value pair whose key is key and whose value is an 'int' node; false otherwise.
    • hasLong

      public boolean hasLong(String key)
      Returns true if this map node contains a key–value pair whose key is the specified key and whose value is a 'long' node.
      Parameters:
      key - the key of the key–value pair of interest.
      Returns:
      true if this map node contains a key–value pair whose key is key and whose value is a 'long' node; false otherwise.
    • hasIntOrLong

      public boolean hasIntOrLong(String key)
      Returns true if this map node contains a key–value pair whose key is the specified key and whose value is either an 'int' node or a 'long' node.
      Parameters:
      key - the key of the key–value pair of interest.
      Returns:
      true if this map node contains a key–value pair whose key is key and whose value is either an 'int' node or a 'long' node; false otherwise.
    • hasDouble

      public boolean hasDouble(String key)
      Returns true if this map node contains a key–value pair whose key is the specified key and whose value is a 'double' node.
      Parameters:
      key - the key of the key–value pair of interest.
      Returns:
      true if this map node contains a key–value pair whose key is key and whose value is a 'double' node; false otherwise.
    • hasString

      public boolean hasString(String key)
      Returns true if this map node contains a key–value pair whose key is the specified key and whose value is a string node.
      Parameters:
      key - the key of the key–value pair of interest.
      Returns:
      true if this map node contains a key–value pair whose key is key and whose value is a string node; false otherwise.
    • hasList

      public boolean hasList(String key)
      Returns true if this map node contains a key–value pair whose key is the specified key and whose value is a list node.
      Parameters:
      key - the key of the key–value pair of interest.
      Returns:
      true if this map node contains a key–value pair whose key is key and whose value is a list node; false otherwise.
    • hasMap

      public boolean hasMap(String key)
      Returns true if this map node contains a key–value pair whose key is the specified key and whose value is a map node.
      Parameters:
      key - the key of the key–value pair of interest.
      Returns:
      true if this map node contains a key–value pair whose key is key and whose value is a map node; false otherwise.
    • get

      public AbstractNode get(String key)
      Returns the value of the key–value pair of this map node with the specified key.
      Parameters:
      key - the key of the key–value pair whose value is desired.
      Returns:
      the value of the key–value pair of this map node whose key is key, or null if this map node does not contain a KV pair with such a key.
    • getNullNode

      public NullNode getNullNode(String key)
      Returns the null node that is associated with the specified key in this map node.
      Parameters:
      key - the key of the key–value pair whose value is desired.
      Returns:
      the null node that is associated with key in this map node, or null if this map node does not contain a KV pair with such a key.
      Throws:
      ClassCastException - if this map node contains a KV pair with the specified key and its value is not an instance of NullNode.
    • getBooleanNode

      public BooleanNode getBooleanNode(String key)
      Returns the Boolean node that is associated with the specified key in this map node.
      Parameters:
      key - the key of the key–value pair whose value is desired.
      Returns:
      the Boolean node that is associated with key in this map node, or null if this map node does not contain a KV pair with such a key.
      Throws:
      ClassCastException - if this map node contains a KV pair with the specified key and its value is not an instance of BooleanNode.
    • getBoolean

      public boolean getBoolean(String key)
      Returns the underlying value of the Boolean node that is associated with the specified key in this map node.
      Parameters:
      key - the key of the key–value pair whose underlying value is desired.
      Returns:
      the underlying value of the Boolean node that is associated with key in this map node.
      Throws:
      NullPointerException - if this map node does not contain a KV pair with the specified key.
      ClassCastException - if this map node contains a KV pair with the specified key and its value is not an instance of BooleanNode.
    • getBoolean

      public boolean getBoolean(String key, boolean defaultValue)
      Returns the underlying value of the Boolean node that is associated with the specified key in this map node. If this map node does not contain a key–value pair with such a key, or if the associated value is not a Boolean node, the specified default value is returned instead.
      Parameters:
      key - the key of the key–value pair whose underlying value is desired.
      defaultValue - the value that will be returned if this map node does not contain a key–value pair whose key is key or the value of the pair is not a Boolean node.
      Returns:
      the underlying value of the Boolean node that is associated with key in this map node, or defaultValue if there is no such node.
    • getIntNode

      public IntNode getIntNode(String key)
      Returns the 'int' node that is associated with the specified key in this map node.
      Parameters:
      key - the key of the key–value pair whose value is desired.
      Returns:
      the 'int' node that is associated with key in this map node, or null if this map node does not contain a KV pair with such a key.
      Throws:
      ClassCastException - if this map node contains a KV pair with the specified key and its value is not an instance of IntNode.
    • getInt

      public int getInt(String key)
      Returns the underlying value of the 'int' node that is associated with the specified key in this map node.
      Parameters:
      key - the key of the key–value pair whose underlying value is desired.
      Returns:
      the underlying value of the 'int' node that is associated with key in this map node.
      Throws:
      NullPointerException - if this map node does not contain a KV pair with the specified key.
      ClassCastException - if this map node contains a KV pair with the specified key and its value is not an instance of IntNode.
    • getInt

      public int getInt(String key, int defaultValue)
      Returns the underlying value of the 'int' node that is associated with the specified key in this map node. If this map node does not contain a key–value pair with such a key, or if the associated value is not an 'int' node, the specified default value is returned instead.
      Parameters:
      key - the key of the key–value pair whose underlying value is desired.
      defaultValue - the value that will be returned if this map node does not contain a key–value pair whose key is key or the value of the pair is not an 'int' node.
      Returns:
      the underlying value of the 'int' node that is associated with key in this map node, or defaultValue if there is no such node.
    • getLongNode

      public LongNode getLongNode(String key)
      Returns the 'long' node that is associated with the specified key in this map node.
      Parameters:
      key - the key of the key–value pair whose value is desired.
      Returns:
      the 'long' node that is associated with key in this map node, or null if this map node does not contain a KV pair with such a key.
      Throws:
      ClassCastException - if this map node contains a KV pair with the specified key and its value is not an instance of LongNode.
    • getLong

      public long getLong(String key)
      Returns the underlying value of the 'long' node that is associated with the specified key in this map node.
      Parameters:
      key - the key of the key–value pair whose underlying value is desired.
      Returns:
      the underlying value of the 'long' node that is associated with key in this map node.
      Throws:
      NullPointerException - if this map node does not contain a KV pair with the specified key.
      ClassCastException - if this map node contains a KV pair with the specified key and its value is not an instance of LongNode.
    • getLong

      public long getLong(String key, long defaultValue)
      Returns the underlying value of the 'long' node that is associated with the specified key in this map node. If this map node does not contain a key–value pair with such a key, or if the associated value is not a 'long' node, the specified default value is returned instead.
      Parameters:
      key - the key of the key–value pair whose underlying value is desired.
      defaultValue - the value that will be returned if this map node does not contain a key–value pair whose key is key or the value of the pair is not a 'long' node.
      Returns:
      the underlying value of the 'long' node that is associated with key in this map node, or defaultValue if there is no such node.
    • getIntOrLong

      public long getIntOrLong(String key)
      Returns the underlying value of the 'int' node or 'long' node that is associated with the specified key in this map node.
      Parameters:
      key - the key of the key–value pair whose underlying value is desired.
      Returns:
      the underlying value of the 'int' node or 'long' node that is associated with key in this map node.
      Throws:
      NullPointerException - if this map node does not contain a KV pair with the specified key.
      NodeTypeException - if this map node contains a KV pair with the specified key and its value is neither an instance of IntNode nor an instance of LongNode.
    • getIntOrLong

      public long getIntOrLong(String key, long defaultValue)
      Returns the underlying value of the 'int' node or 'long' node that is associated with the specified key in this map node. If this map node does not contain a key–value pair with such a key, or if the associated value is neither an 'int' node nor a 'long' node, the specified default value is returned instead.
      Parameters:
      key - the key of the key–value pair whose underlying value is desired.
      defaultValue - the value that will be returned if this map node does not contain a key–value pair whose key is key or the value of the pair is neither an 'int' node nor a 'long' node.
      Returns:
      the underlying value of the 'int' node or 'long' node that is associated with key in this map node, or defaultValue if there is no such node.
    • getDoubleNode

      public DoubleNode getDoubleNode(String key)
      Returns the 'double' node that is associated with the specified key in this map node.
      Parameters:
      key - the key of the key–value pair whose value is desired.
      Returns:
      the 'double' node that is associated with key in this map node, or null if this map node does not contain a KV pair with such a key.
      Throws:
      ClassCastException - if this map node contains a KV pair with the specified key and its value is not an instance of DoubleNode.
    • getDouble

      public double getDouble(String key)
      Returns the underlying value of the 'double' node that is associated with the specified key in this map node.
      Parameters:
      key - the key of the key–value pair whose underlying value is desired.
      Returns:
      the underlying value of the 'double' node that is associated with key in this map node.
      Throws:
      NullPointerException - if this map node does not contain a KV pair with the specified key.
      ClassCastException - if this map node contains a KV pair with the specified key and its value is not an instance of DoubleNode.
    • getDouble

      public double getDouble(String key, double defaultValue)
      Returns the underlying value of the 'double' node that is associated with the specified key in this map node. If this map node does not contain a key–value pair with such a key, or if the associated value is not a 'double' node, the specified default value is returned instead.
      Parameters:
      key - the key of the key–value pair whose underlying value is desired.
      defaultValue - the value that will be returned if this map node does not contain a key–value pair whose key is key or the value of the pair is not a 'double' node.
      Returns:
      the underlying value of the 'double' node that is associated with key in this map node, or defaultValue if there is no such node.
    • getStringNode

      public StringNode getStringNode(String key)
      Returns the string node that is associated with the specified key in this map node.
      Parameters:
      key - the key of the key–value pair whose value is desired.
      Returns:
      the string node that is associated with key in this map node, or null if this map node does not contain a KV pair with such a key.
      Throws:
      ClassCastException - if this map node contains a KV pair with the specified key and its value is not an instance of StringNode.
    • getString

      public String getString(String key)
      Returns the underlying value of the string node that is associated with the specified key in this map node.
      Parameters:
      key - the key of the key–value pair whose underlying value is desired.
      Returns:
      the underlying value of the string node that is associated with key in this map node.
      Throws:
      NullPointerException - if this map node does not contain a KV pair with the specified key.
      ClassCastException - if this map node contains a KV pair with the specified key and its value is not an instance of StringNode.
    • getString

      public String getString(String key, String defaultValue)
      Returns the underlying value of the string node that is associated with the specified key in this map node. If this map node does not contain a key–value pair with such a key, or if the associated value is not a string node, the specified default value is returned instead.
      Parameters:
      key - the key of the key–value pair whose underlying value is desired.
      defaultValue - the value that will be returned if this map node does not contain a key–value pair whose key is key or the value of the pair is not a string node.
      Returns:
      the underlying value of the string node that is associated with key in this map node, or defaultValue if there is no such node.
    • getListNode

      public ListNode getListNode(String key)
      Returns the list node that is associated with the specified key in this map node.
      Parameters:
      key - the key of the key–value pair whose value is desired.
      Returns:
      the list node that is associated with key in this map node, or null if this map node does not contain a KV pair with such a key.
      Throws:
      ClassCastException - if this map node contains a KV pair with the specified key and its value is not an instance of ListNode.
    • getMapNode

      public MapNode getMapNode(String key)
      Returns the map node that is associated with the specified key in this map node.
      Parameters:
      key - the key of the key–value pair whose value is desired.
      Returns:
      the map node that is associated with key in this map node, or null if this map node does not contain a KV pair with such a key.
      Throws:
      ClassCastException - if this map node contains a KV pair with the specified key and its value is not an instance of MapNode.
    • getEnumValue

      public <E extends Enum<E>> E getEnumValue(Class<E> cls, String key, E defaultValue)
      Returns the constant of the specified enumeration type whose name matches the underlying value of the string node that is associated with the specified key in this map node. If this map node does not contain a key–value pair with such a key, or if the associated value is not a string node, or if the value of the string node does not match the name of any of the enumeration constants, the specified default value is returned instead.
      Type Parameters:
      E - the enumeration type.
      Parameters:
      cls - the class of the enumeration type.
      key - the key of the key–value pair whose underlying value is required to match the name of an enumeration constant of cls.
      defaultValue - the value that will be returned if this map node does not contain a key–value pair whose key is key or the value of the pair is not a string node or the value of the string node does not match the name of any of the enumeration constants.
      Returns:
      the enumeration constant of cls whose name matches the the underlying value of the string node that is associated with key in this map node, or defaultValue if there is no such node or there is no matching enumeration constant.
    • getEnumValue

      public <E extends Enum<E>> E getEnumValue(Class<E> cls, String key, Function<E,String> converter, E defaultValue)
      Returns the constant of the specified enumeration type that, after the specified converter has been applied to it, matches the underlying value of the string node that is associated with the specified key in this map node. If this map node does not contain a key–value pair with such a key, or if the associated value is not a string node, or if the value of the string node does not match any of the converted enumeration constants, the specified default value is returned instead.
      Type Parameters:
      E - the enumeration type.
      Parameters:
      cls - the class of the enumeration type.
      key - the key of the key–value pair whose underlying value is required to match an enumeration constant of cls after converter has been applied to it.
      converter - the function that converts the enumeration constants of cls to strings.
      defaultValue - the value that will be returned if this map node does not contain a key–value pair whose key is key or the value of the pair is not a string node or the value of the string node does not match any of the converted enumeration constants.
      Returns:
      the enumeration constant of cls that, after converter has been applied to it, matches the the underlying value of the string node that is associated with key in this map node, or defaultValue if there is no such node or there is no matching enumeration constant.
    • getKeys

      public List<String> getKeys()
      Returns a list of the keys of the key–value pairs of this map node. The keys are in the order in which their associated KV pairs were added to this map node. The list is independent of this map node, so it may be modified without affecting this node.
      Returns:
      a list of the keys of the key–value pairs of this map node.
      See Also:
    • getPairs

      public Map<String,AbstractNode> getPairs()
      Returns an unmodifiable map of the key–value pairs of this map node. Iterating over the entries of the map will traverse the KV pairs in the order in which they were added to this map node. Although the returned map cannot be modified, the values of its KV pairs can be modified, and doing so (for example, changing the parent of a node) will affect this map node.
      Returns:
      an unmodifiable map of the key–value pairs of this map node.
      See Also:
    • getPairIterator

      public Iterator<Map.Entry<String,AbstractNode>> getPairIterator()
      Returns an iterator over the key–value pairs of this map node.
      Returns:
      an iterator over the key–value pairs of this map node.
    • getPairList

      public List<MapNode.Pair> getPairList()
      Returns a list of the key–value pairs of this map node. Iterating over the list will traverse the KV pairs in the order in which they were added to this map node. Modifying the value of a KV pair (for example, changing the parent of a node) will affect this map node.
      Returns:
      a list of the key–value pairs of this map node.
      See Also:
    • findKey

      public String findKey(AbstractNode value)
      Returns the key that is associated with the specified value in this map node. Values are tested for identity, not for equality; that is, two values, v1 and v2, match if and only if v1 == v2.
      Parameters:
      value - the value whose associated key is desired.
      Returns:
      the key that is associated with value in this map node, or null if there is no such key.
    • clear

      public void clear()
      Removes all the key–value pairs of this map node.
    • setPairs

      public void setPairs(Map<String,AbstractNode> pairs)
      Sets the key–value pairs of this map node to the specified pairs of keys and values.
      Parameters:
      pairs - the pairs of keys and values to which the key–value pairs of this map node will be set.
    • add

      public void add(MapNode.Pair pair)
      Adds the specified key–value pair to this map node. If this map node already contains a KV pair with the key of the new pair, the new pair will replace the existing pair without affecting the order of the pairs; otherwise, the specified pair will be added to the end of the collection of pairs.
      Parameters:
      pair - the key–value pair that will be added to this map node.
      Throws:
      IllegalArgumentException - if pair is null.
    • add

      public void add(String key, AbstractNode value)
      Adds a key–value pair with the specified key and value to this map node. If this map node already contains a KV pair with the specified key, the specified value will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of KV pairs.
      Parameters:
      key - the key of the key–value pair.
      value - the value of the key–value pair.
      Throws:
      IllegalArgumentException - if key is null or value is null.
    • addIfAbsent

      public <T extends AbstractNode> T addIfAbsent(String key, T value)

      Adds a key–value pair with the specified key and value to this map node if it does not already contain a KV pair with the specified key.

      • If this node already contains a KV pair with the specified key, a ClassCastException is thrown if the type of the existing value is different from the type of the specified value. If the types of the existing value and the specified value are the same, the existing value is returned. This node is not modified.
      • If this node does not contain a KV pair with the specified key, a new KV pair will be added to the end of the collection of KV pairs.
      Type Parameters:
      T - the type of the value that will be added to this map node if it does not already contain a key–value pair with the specified key.
      Parameters:
      key - the key of the key–value pair.
      value - the value of the key–value pair.
      Returns:
      the value that is associated with key in this node's collection of KV pairs.
      Throws:
      IllegalArgumentException - if key is null or value is null.
      ClassCastException - if this map node already contains an entry for key but the type of the associated value is different from the type of value.
    • addPairs

      public void addPairs(MapNode.Pair... pairs)
      Adds the specified key–value pairs to the key–value pairs of this map node. For each of the new pairs, if this node already contains a KV pair with the key of the new pair, the value of the new pair will replace the value of the existing pair without affecting the order of the pairs; otherwise, the new KV pair will be added to the end of the collection of pairs. The KV pairs are added in the order in which they are traversed by their iterator.
      Parameters:
      pairs - the key–value pairs that will be added to the key–value pairs of this map node.
    • addPairs

      public void addPairs(Iterable<? extends MapNode.Pair> pairs)
      Adds the specified key–value pairs to the key–value pairs of this map node. For each of the new pairs, if this node already contains a KV pair with the key of the new pair, the value of the new pair will replace the value of the existing pair without affecting the order of the pairs; otherwise, the new KV pair will be added to the end of the collection of pairs. The KV pairs are added in the order in which they are traversed by their iterator.
      Parameters:
      pairs - the key–value pairs that will be added to the key–value pairs of this map node.
    • addPairs

      public void addPairs(Map<String,AbstractNode> pairs)
      Adds the specified pairs of keys and values to the key–value pairs of this map node. For each of the new pairs, if this node already contains a KV pair with the key of the new pair, the value of the new pair will replace the value of the existing pair without affecting the order of the pairs; otherwise, the new KV pair will be added to the end of the collection of pairs. The KV pairs are added in the order in which they are traversed by the iterator over the entries of the input map.
      Parameters:
      pairs - the pairs of keys and values that will be added to the key–value pairs of this map node.
    • addNull

      public NullNode addNull(String key)
      Creates a new instance of a null node, adds it to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new null node will be associated.
      Returns:
      the null node that was created and added to this map node as a key–value pair whose key is key.
    • addBoolean

      public BooleanNode addBoolean(String key, boolean value)
      Creates a new instance of a Boolean node, adds it to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new Boolean node will be associated.
      value - the value of the new Boolean node.
      Returns:
      the Boolean node that was created and added to this map node as a key–value pair whose key is key.
    • addBooleans

      public ListNode addBooleans(String key, boolean... values)
      Creates a new instance of a list node whose elements are new instances of Boolean nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new list node will be associated.
      values - the values for which a list node containing Boolean nodes will be created.
      Returns:
      the new list node that contains the Boolean nodes that were created from values and that was added to this map node as a key–value pair whose key is key.
    • addBooleans

      public ListNode addBooleans(String key, Iterable<Boolean> values)
      Creates a new instance of a list node whose elements are new instances of Boolean nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new list node will be associated.
      values - the values for which a list node containing Boolean nodes will be created.
      Returns:
      the new list node that contains the Boolean nodes that were created from values and that was added to this map node as a key–value pair whose key is key.
    • addInt

      public IntNode addInt(String key, int value)
      Creates a new instance of an 'int' node, adds it to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new 'int' node will be associated.
      value - the value of the new 'int' node.
      Returns:
      the 'int' node that was created and added to this map node as a key–value pair whose key is key.
    • addInts

      public ListNode addInts(String key, int... values)
      Creates a new instance of a list node whose elements are new instances of 'int' nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new list node will be associated.
      values - the values for which a list node containing 'int' nodes will be created.
      Returns:
      the new list node that contains the 'int' nodes that were created from values and that was added to this map node as a key–value pair whose key is key.
    • addInts

      public ListNode addInts(String key, Iterable<Integer> values)
      Creates a new instance of a list node whose elements are new instances of 'int' nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new list node will be associated.
      values - the values for which a list node containing 'int' nodes will be created.
      Returns:
      the new list node that contains the 'int' nodes that were created from values and that was added to this map node as a key–value pair whose key is key.
    • addLong

      public LongNode addLong(String key, long value)
      Creates a new instance of a 'long' node, adds it to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new 'long' node will be associated.
      value - the value of the new 'long' node.
      Returns:
      the 'long' node that was created and added to this map node as a key–value pair whose key is key.
    • addLongs

      public ListNode addLongs(String key, long... values)
      Creates a new instance of a list node whose elements are new instances of 'long' nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new list node will be associated.
      values - the values for which a list node containing 'long' nodes will be created.
      Returns:
      the new list node that contains the 'long' nodes that were created from values and that was added to this map node as a key–value pair whose key is key.
    • addLongs

      public ListNode addLongs(String key, Iterable<Long> values)
      Creates a new instance of a list node whose elements are new instances of 'long' nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new list node will be associated.
      values - the values for which a list node containing 'long' nodes will be created.
      Returns:
      the new list node that contains the 'long' nodes that were created from values and that was added to this map node as a key–value pair whose key is key.
    • addDouble

      public DoubleNode addDouble(String key, double value)
      Creates a new instance of a 'double' node, adds it to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new 'double' node will be associated.
      value - the value of the new 'double' node.
      Returns:
      the 'double' node that was created and added to this map node as a key–value pair whose key is key.
    • addDoubles

      public ListNode addDoubles(String key, double... values)
      Creates a new instance of a list node whose elements are new instances of 'double' nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new list node will be associated.
      values - the values for which a list node containing 'double' nodes will be created.
      Returns:
      the new list node that contains the 'double' nodes that were created from values and that was added to this map node as a key–value pair whose key is key.
    • addDoubles

      public ListNode addDoubles(String key, Iterable<Double> values)
      Creates a new instance of a list node whose elements are new instances of 'double' nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new list node will be associated.
      values - the values for which a list node containing 'double' nodes will be created.
      Returns:
      the new list node that contains the 'double' nodes that were created from values and that was added to this map node as a key–value pair whose key is key.
    • addString

      public StringNode addString(String key, String value)
      Creates a new instance of a string node, adds it to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new string node will be associated.
      value - the value of the new string node.
      Returns:
      the string node that was created and added to this map node as a key–value pair whose key is key.
    • addStrings

      public ListNode addStrings(String key, String... values)
      Creates a new instance of a list node whose elements are new instances of string nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new list node will be associated.
      values - the values for which a list node containing string nodes will be created.
      Returns:
      the new list node that contains the string nodes that were created from values and that was added to this map node as a key–value pair whose key is key.
    • addStrings

      public ListNode addStrings(String key, Iterable<String> values)
      Creates a new instance of a list node whose elements are new instances of string nodes with the specified values, adds the list node to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new list node will be associated.
      values - the values for which a list node containing string nodes will be created.
      Returns:
      the new list node that contains the string nodes that were created from values and that was added to this map node as a key–value pair whose key is key.
    • addList

      public ListNode addList(String key, AbstractNode... elements)
      Creates a new instance of a list node that contains the specified elements, adds it to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new list node will be associated.
      elements - the elements of the new list node.
      Returns:
      the new list node that contains elements and that was added to this map node as a key–value pair whose key is key.
    • addList

      public ListNode addList(String key, Iterable<? extends AbstractNode> elements)
      Creates a new instance of a list node that contains the specified elements, adds it to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new list node will be associated.
      elements - the elements of the new list node.
      Returns:
      the new list node that contains elements and that was added to this map node as a key–value pair whose key is key.
    • addMap

      public MapNode addMap(String key, MapNode.Pair... pairs)
      Creates a new instance of a map node that contains the specified pairs of keys and values, adds the new map node to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new map node will be associated.
      pairs - the key–value pairs of the new map node.
      Returns:
      the new map node that contains pairs and that was added to this map node as a key–value pair whose key is key.
    • addMap

      public MapNode addMap(String key, Iterable<? extends MapNode.Pair> pairs)
      Creates a new instance of a map node that contains the specified pairs of keys and values, adds the new map node to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new map node will be associated.
      pairs - the key–value pairs of the new map node.
      Returns:
      the new map node that contains pairs and that was added to this map node as a key–value pair whose key is key.
    • addMap

      public MapNode addMap(String key, Map<String,AbstractNode> pairs)
      Creates a new instance of a map node that contains the specified pairs of keys and values, adds the new map node to this map node as a key–value pair with the specified key and returns it. If this map node already contains a KV pair with the specified key, the new node will replace the value of the existing pair without affecting the order of the pairs; otherwise, a new KV pair will be added to the end of the collection of pairs.
      Parameters:
      key - the key with which the new map node will be associated.
      pairs - the key–value pairs of the new map node.
      Returns:
      the new map node that contains pairs and that was added to this map node as a key–value pair whose key is key.
    • remove

      public void remove(String... keys)
      Removes the key–value pairs with the specified keys from this map node. For each of the specified keys, if the key is not associated with a KV pair of this map node, it is ignored.
      Parameters:
      keys - the keys of the key–value pairs that will be removed from this map node.
    • remove

      public void remove(Iterable<String> keys)
      Removes the key–value pairs with the specified keys from this map node. For each of the specified keys, if the key is not associated with a KV pair of this map node, it is ignored.
      Parameters:
      keys - the keys of the key–value pairs that will be removed from this map node.
    • remove

      public void remove(Predicate<String> keyFilter)
      Removes from this map node the key–value pairs whose keys are accepted by the specified filter.
      Parameters:
      keyFilter - the function that selects the keys of the key–value pairs that will be removed from this map node.
    • retain

      public void retain(String... keys)
      Removes all key–value pairs from this map node except for those with the specified keys.
      Parameters:
      keys - the keys of the key–value pairs that will be retained by this map node.
    • retain

      public void retain(Collection<String> keys)
      Removes all key–value pairs from this map node except for those with the specified keys.
      Parameters:
      keys - the keys of the key–value pairs that will be retained by this map node.
    • retain

      public void retain(Predicate<String> keyFilter)
      Removes all key–value pairs from this map node except for those whose keys are accepted by the specified filter.
      Parameters:
      keyFilter - the function that selects the keys of the key–value pairs that will be retained by this map node.
    • sort

      public void sort()
      Sorts the key–value pairs of this map node into ascending order of their keys by applying the String.compareTo(String) method to the keys.
    • sort

      public void sort(Comparator<String> keyComparator)
      Sorts the key–value pairs of this map node by applying the specified comparator to their keys.
      Parameters:
      keyComparator - the comparator that will be applied to the keys of this map node to determine the order of the key–value pairs. If it is null, the keys will be sorted by applying the String.compareTo(String) method to them.