Class Pair<L,R>

java.lang.Object
tk.airshipcraft.commonlib.utils.Pair<L,R>
Type Parameters:
L - The type of the left element.
R - The type of the right element.

public class Pair<L,R> extends Object
A utility class representing a pair of objects.
Since:
2023-10-11
Version:
1.0.0
Author:
eerieXanthic, notzune
  • Constructor Summary

    Constructors
    Constructor
    Description
    Pair(L left, R right)
    Constructs a new Pair with the specified values.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    Returns the left element of the pair.
    Returns the right element of the pair.
    int
     
    static <L, R> Pair<L,R>
    of(L left, R right)
    Creates a new Pair with the specified values.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Pair

      public Pair(L left, R right)
      Constructs a new Pair with the specified values.
      Parameters:
      left - The left element, must not be null.
      right - The right element, must not be null.
      Throws:
      NullPointerException - if either left or right is null.
  • Method Details

    • of

      public static <L, R> Pair<L,R> of(L left, R right)
      Creates a new Pair with the specified values. This method is a shorthand for creating a new Pair instance.
      Type Parameters:
      L - The type of the left element.
      R - The type of the right element.
      Parameters:
      left - The left element, must not be null.
      right - The right element, must not be null.
      Returns:
      A new Pair<L, R> instance.
      Throws:
      NullPointerException - if either left or right is null.
    • getLeft

      public L getLeft()
      Returns the left element of the pair.
      Returns:
      The left element.
    • getRight

      public R getRight()
      Returns the right element of the pair.
      Returns:
      The right element.
    • hashCode

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

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

      public String toString()
      Overrides:
      toString in class Object