Package net.cscott.jutil
Record Class Pair<A,B>
java.lang.Object
java.lang.Record
net.cscott.jutil.Pair<A,B>
- Type Parameters:
A- the type of the left elementB- the type of the right element- Record Components:
left- the left element of the pair (head)right- the right element of the pair (tail)
- All Implemented Interfaces:
Serializable
An immutable pair of values, either of which may be
null. Two Pairs are equal when their left
values are equal and their right values are equal, so pairs can be
keys in hash tables. A Pair is serializable if its values
are.
Pair replaces Default.PairList, which is a mutable
List of two Objects. For a pair which is
a Map.Entry, use PairMapEntry or
AbstractMap.SimpleImmutableEntry.
- Since:
- 2.0
- Author:
- C. Scott Ananian <cananian@alumni.princeton.edu>
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.left()Returns the value of theleftrecord component.right()Returns the value of therightrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
left
Returns the value of theleftrecord component.- Returns:
- the value of the
leftrecord component
-
right
Returns the value of therightrecord component.- Returns:
- the value of the
rightrecord component
-