Class Pair<K,V>

java.lang.Object
org.pgcodekeeper.core.utils.Pair<K,V>
Type Parameters:
K - type of the first element
V - type of the second element
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ModPair

public class Pair<K,V> extends Object implements Serializable
Immutable pair utility class for holding two related objects. Objects of this class are unmodifiable. Use ModPair and copyMod() to get modifiable Pairs.
See Also:
  • Constructor Details

    • Pair

      public Pair(K first, V second)
      Creates a new immutable pair with specified elements.
      Parameters:
      first - the first element
      second - the second element
  • Method Details

    • getFirst

      public K getFirst()
      Returns the first element of this pair.
      Returns:
      the first element
    • getSecond

      public V getSecond()
      Returns the second element of this pair.
      Returns:
      the second element
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • copy

      public Pair<K,V> copy()
      Creates an immutable copy of this pair.
      Returns:
      new immutable Pair with same elements
    • copyMod

      public ModPair<K,V> copyMod()
      Creates a modifiable copy of this pair.
      Returns:
      new ModPair with same elements