Class MapNode.Pair

java.lang.Object
uk.blankaspect.common.basictree.MapNode.Pair
All Implemented Interfaces:
Cloneable
Enclosing class:
MapNode

public static class MapNode.Pair extends Object implements Cloneable
This class encapsulates a key–value pair of a map node. The key is a string and the value is a node.
  • Constructor Details

    • Pair

      public Pair(String key, AbstractNode value)
      Creates a new instance of a key–value pair of a map node.
      Parameters:
      key - the key of the key–value pair.
      value - the value of the key–value pair.
  • Method Details

    • setKeyConverter

      public static void setKeyConverter(Function<CharSequence,String> converter)
      Sets the function that converts the key of a key–value pair to its string representation for the toString() method. The default converter is the method StringNode.escapeAndQuote(CharSequence).
      Parameters:
      converter - the function that converts the key of a key–value pair to a string representation.
    • equals

      public boolean equals(Object obj)
      Returns true if the specified object is an instance of Pair and the keys and values of the two pairs are equal to each other.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object with which this KV pair will be compared.
      Returns:
      true if obj is an instance of Pair and the keys and values of the two pairs are equal to each other; false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash code of this key–value pair.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code of this key–value pair.
    • clone

      public MapNode.Pair clone()
      Creates and returns a copy of this key–value pair.
      Overrides:
      clone in class Object
      Returns:
      a copy of this key–value pair.
    • toString

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

      public String getKey()
      Returns the key of this key–value pair.
      Returns:
      the key of this key–value pair.
    • getValue

      public AbstractNode getValue()
      Returns the value of this key–value pair.
      Returns:
      the value of this key–value pair.