Class Tuple4<A,B,C,D>

java.lang.Object
org.apache.juneau.commons.function.Tuple4<A,B,C,D>
Type Parameters:
A - Object 1 type.
B - Object 2 type.
C - Object 3 type.
D - Object 4 type.

public class Tuple4<A,B,C,D> extends Object
Represents a simple tuple of 4 objects.

This class is useful when you need a four-value composite key for HashMap lookups that properly implements equals(Object) and hashCode() based on content rather than identity.

Array Support:

Unlike using arrays directly as HashMap keys, this class properly handles arrays by using content-based equality and hashing via HashCode.of(Object...) which internally uses Arrays.hashCode(Object[]) for arrays.

See Also:
  • Constructor Details

    • Tuple4

      public Tuple4(A a, B b, C c, D d)
      Constructor.
      Parameters:
      a - Object 1.
      b - Object 2.
      c - Object 3.
      d - Object 4.
  • Method Details

    • of

      public static <A, B, C, D> Tuple4<A,B,C,D> of(A a, B b, C c, D d)
      Static creator.
      Type Parameters:
      A - Object 1 type.
      B - Object 2 type.
      C - Object 3 type.
      D - Object 4 type.
      Parameters:
      a - Object 1.
      b - Object 2.
      c - Object 3.
      d - Object 4.
      Returns:
      A new tuple object.
    • equals

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

      public A getA()
      Returns the first object in this tuple.
      Returns:
      The first object in this tuple.
    • getB

      public B getB()
      Returns the second object in this tuple.
      Returns:
      The second object in this tuple.
    • getC

      public C getC()
      Returns the third object in this tuple.
      Returns:
      The third object in this tuple.
    • getD

      public D getD()
      Returns the fourth object in this tuple.
      Returns:
      The fourth object in this tuple.
    • optA

      public Optional<A> optA()
      Returns the first object in this tuple wrapped in an Optional.
      Returns:
      The first object wrapped in an Optional, or Optional.empty() if the value is null.
    • optB

      public Optional<B> optB()
      Returns the second object in this tuple wrapped in an Optional.
      Returns:
      The second object wrapped in an Optional, or Optional.empty() if the value is null.
    • optC

      public Optional<C> optC()
      Returns the third object in this tuple wrapped in an Optional.
      Returns:
      The third object wrapped in an Optional, or Optional.empty() if the value is null.
    • optD

      public Optional<D> optD()
      Returns the fourth object in this tuple wrapped in an Optional.
      Returns:
      The fourth object wrapped in an Optional, or Optional.empty() if the value is null.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object