Class Pair<E1,E2>

java.lang.Object
ch.nolix.base.datastructure.pair.Pair<E1,E2>
Type Parameters:
E1 - is the type of the element 1 of a Pair.
E2 - is the type of the element 2 of a Pair.
All Implemented Interfaces:
IPair<E1,E2>

public final class Pair<E1,E2> extends Object implements IPair<E1,E2>
A Pair contains 2 elements. A Pair is not mutable.
Author:
Silvan Wyss
  • Method Details

    • withElement1AndElement2

      public static <T1,T2> Pair<T1,T2> withElement1AndElement2(T1 element1, T2 element2)
      Type Parameters:
      T1 - is the type of the given element1.
      T2 - is the type of the given element2.
      Parameters:
      element1 -
      element2 -
      Returns:
      a new Pair with the given element1 and element2.
      Throws:
      RuntimeException - if the given element 1 is null.
      RuntimeException - if the given element 2 is null.
    • getStoredElement1

      public E1 getStoredElement1()
      Specified by:
      getStoredElement1 in interface IPair<E1,E2>
      Returns:
      the element1 of the current IPair.
    • getStoredElement2

      public E2 getStoredElement2()
      Specified by:
      getStoredElement2 in interface IPair<E1,E2>
      Returns:
      the element2 of the current IPair.
    • hasElement1

      public boolean hasElement1(Object object)
      Specified by:
      hasElement1 in interface IPair<E1,E2>
      Parameters:
      object -
      Returns:
      true if the element1 of the current IPair is the given object, false otherwise.
    • hasElement2

      public boolean hasElement2(Object object)
      Specified by:
      hasElement2 in interface IPair<E1,E2>
      Parameters:
      object -
      Returns:
      true if the element2 of the current IPair is the given object, false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object