Package com.yahoo.collections
Class Tuple2<T1,T2>
- java.lang.Object
-
- com.yahoo.collections.Tuple2<T1,T2>
-
public final class Tuple2<T1,T2> extends java.lang.Object
A representation of a pair of values, typically of different types.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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
equals(Object) will always throw UnsupportedOperationException.int
hashCode()
hashCode() will always throw UnsupportedOperationException.java.lang.String
toString()
Human readable string representation which invokes the contained instances' toString() implementation.
-
-
-
Method Detail
-
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 classjava.lang.Object
- Throws:
java.lang.UnsupportedOperationException
- will always throw this when invoked
-
equals
public boolean equals(java.lang.Object obj)
equals(Object) will always throw UnsupportedOperationException. The intention is always using the objects contained in the tuple directly.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- ignored- Throws:
java.lang.UnsupportedOperationException
- will always throw this when invoked
-
toString
public java.lang.String toString()
Human readable string representation which invokes the contained instances' toString() implementation.- Overrides:
toString
in classjava.lang.Object
-
-