Class Tuple2<T1,T2>

java.lang.Object
com.yahoo.collections.Tuple2<T1,T2>

public final class Tuple2<T1,T2> extends Object
A pair of values. This class is to avoid littering a class with thin wrapper objects for passing around e.g. the state of an operation and the result value. Using this class may be correct, but it is a symptom that you may want to redesign your code. (Should you pass mutable objects to the method instead? Create a new class and do the work inside that class instead? Etc.)
Author:
Steinar Knutsen
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final T1
     
    final T2
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Tuple2(T1 first, T2 second)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object) will always throw UnsupportedOperationException.
    int
    hashCode() will always throw UnsupportedOperationException.
    Human readable string representation which invokes the contained instances' toString() implementation.

    Methods inherited from class java.lang.Object

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

    • first

      public final T1 first
    • second

      public final T2 second
  • Constructor Details

    • Tuple2

      public Tuple2(T1 first, T2 second)
  • Method Details

    • hashCode

      public int hashCode()
      hashCode() will always throw UnsupportedOperationException. The reason is this class is not meant for being put in Container implementation or similar use where Java generics will lead to a type unsafe maintenance nightmare.
      Overrides:
      hashCode in class Object
      Throws:
      UnsupportedOperationException - will always throw this when invoked
    • equals

      public boolean equals(Object obj)
      equals(Object) will always throw UnsupportedOperationException. The intention is always using the objects contained in the tuple directly.
      Overrides:
      equals in class Object
      Parameters:
      obj - ignored
      Throws:
      UnsupportedOperationException - will always throw this when invoked
    • toString

      public String toString()
      Human readable string representation which invokes the contained instances' toString() implementation.
      Overrides:
      toString in class Object