Record Class Pair<T,U>
java.lang.Object
java.lang.Record
net.tangly.commons.lang.functional.Pair<T,U>
- Type Parameters:
T
- left type of the pairU
- right type of the pair
Defines a typed pair as long as JDK API is not providing the abstraction. Pairs can, for example, be used to return two values from a function. The regular
approach is Java is to define an additional record type.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.left()
Returns the value of theleft
record component.static <T,
U> Pair <T, U> of
(T left, U right) right()
Returns the value of theright
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
Pair
-
-
Method Details
-
of
-
toString
-
hashCode
-
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 theleft
record component.- Returns:
- the value of the
left
record component
-
right
Returns the value of theright
record component.- Returns:
- the value of the
right
record component
-