Class ImmutablePair<L,R>

java.lang.Object
org.camunda.bpm.engine.impl.util.ImmutablePair<L,R>
Type Parameters:
L - the type of the left element
R - the type of the right element
All Implemented Interfaces:
Serializable, Comparable<ImmutablePair<L,R>>, Map.Entry<L,R>

public class ImmutablePair<L,R> extends Object implements Map.Entry<L,R>, Serializable, Comparable<ImmutablePair<L,R>>
Immutable representation of a 2-tuple of elements. Although the implementation is immutable, there is no restriction on the objects that may be stored. If mutable objects are stored in the pair, then the pair itself effectively becomes mutable. ThreadSafe if both paired objects are thread-safe
See Also:
  • Field Details

    • left

      protected L left
  • Constructor Details

    • ImmutablePair

      public ImmutablePair(L left, R right)
      Create a pair of elements.
      Parameters:
      left - the left element
      right - the right element
  • Method Details

    • getLeft

      public L getLeft()
      Returns:
      the left element
    • getRight

      public R getRight()
      Returns:
      the right element
    • getKey

      public final L getKey()
      Specified by:
      getKey in interface Map.Entry<L,R>
    • getValue

      public R getValue()
      Specified by:
      getValue in interface Map.Entry<L,R>
    • setValue

      public R setValue(R value)
      This is not allowed since the pair itself is immutable.
      Specified by:
      setValue in interface Map.Entry<L,R>
      Returns:
      never
      Throws:
      UnsupportedOperationException
    • compareTo

      public int compareTo(ImmutablePair<L,R> o)
      Compares the pair based on the left element followed by the right element. The types must be Comparable.
      Specified by:
      compareTo in interface Comparable<L>
      Parameters:
      other - the other pair, not null
      Returns:
      negative if this is less, zero if equal, positive if greater
    • compare

      protected int compare(Comparable original, Comparable other)
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Map.Entry<L,R>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map.Entry<L,R>
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object