Package wt.util

Class Pair.UnorderedPair<T>

java.lang.Object
wt.util.Pair<T,T>
wt.util.Pair.UnorderedPair<T>
All Implemented Interfaces:
Serializable
Enclosing class:
Pair<T1,T2>

public static class Pair.UnorderedPair<T> extends Pair<T,T>
Aggregates an unordered pair of objects and handles them as a unique combination. Two UnorderedPair objects will test equal if their component objects test equal in either order. A UnorderedPair's hash code is a combination of its component object hash codes, which allows them to be added to collections and used as map keys.

Supported API: true

Extendable: false
See Also:
  • Constructor Details

    • UnorderedPair

      public UnorderedPair()
      Construct a default UnorderedPair with null component objects.

      Supported API: true
    • UnorderedPair

      public UnorderedPair(T obj1, T obj2)
      Construct an UnorderedPair object from components.

      Supported API: true
      Parameters:
      obj1 - Object 1.
      obj2 - Object 2.
    • UnorderedPair

      public UnorderedPair(Pair<T,T> pair)
      Construct an UnorderedPair copy. The pair's individual objects are referenced in the copy, not duplicated.

      Supported API: true
      Parameters:
      pair - Pair object to be copied.
  • Method Details

    • equals

      public boolean equals(Object obj)
      Two UnorderedPairs are equal if their two component objects are equal in either order. A UnorderedPair and a Pair are equal if their two component objects are equal in their defined order only. Component objects are compared using their equals() method.

      Supported API: true
      Overrides:
      equals in class Pair<T,T>
      See Also:
    • equals

      public boolean equals(Pair.UnorderedPair otherPair, boolean reverseOrder)
      Determine if two UnorderedPair objects are equal in a specified order.

      Supported API: true
      Parameters:
      otherPair - Other UnorderedPair to be tested against this one.
      reverseOrder - True to test equality of the component objects in reverse order, false to test in the defined order.
      Returns:
      True if both component objects are equal in the specified order.