Package ch.njol.util

Class Pair<T1,​T2>

java.lang.Object
ch.njol.util.Pair<T1,​T2>
All Implemented Interfaces:
Serializable, Cloneable, Map.Entry<T1,​T2>
Direct Known Subclasses:
NonNullPair

public class Pair<T1,​T2> extends Object implements Map.Entry<T1,​T2>, Cloneable, Serializable
See Also:
Serialized Form
  • Field Details

    • first

      protected @Nullable T1 first
    • second

      protected @Nullable T2 second
  • Constructor Details

    • Pair

      public Pair()
    • Pair

      public Pair(@Nullable T1 first, @Nullable T2 second)
    • Pair

      public Pair(Map.Entry<T1,​T2> e)
  • Method Details

    • getFirst

      public @Nullable T1 getFirst()
    • setFirst

      public void setFirst(@Nullable T1 first)
    • getSecond

      public @Nullable T2 getSecond()
    • setSecond

      public void setSecond(@Nullable T2 second)
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      "first,second"
    • equals

      public final boolean equals(@Nullable Object obj)
      Checks for equality with Entries to match hashCode()
      Specified by:
      equals in interface Map.Entry<T1,​T2>
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      As defined by Map.Entry.hashCode()
      Specified by:
      hashCode in interface Map.Entry<T1,​T2>
      Overrides:
      hashCode in class Object
    • getKey

      public @Nullable T1 getKey()
      Specified by:
      getKey in interface Map.Entry<T1,​T2>
    • getValue

      public @Nullable T2 getValue()
      Specified by:
      getValue in interface Map.Entry<T1,​T2>
    • setValue

      public @Nullable T2 setValue(@Nullable T2 value)
      Specified by:
      setValue in interface Map.Entry<T1,​T2>
    • clone

      public Pair<T1,​T2> clone()
      Overrides:
      clone in class Object
      Returns:
      a shallow copy of this pair