Record Class Pair<L,R>
java.lang.Object
java.lang.Record
org.tquadrat.foundation.lang.Pair<L,R>
- Type Parameters:
L- The type for the left value.R- The type for the right value.- Record Components:
left- The left value of the pair.right- The right value of the pair.
@ClassVersion(sourceVersion="$Id: Pair.java 1151 2025-10-01 21:32:15Z tquadrat $")
@API(status=STABLE,
since="0.1.0")
public record Pair<L,R> (L left, R right)
extends Record
The implementation of a tupel.
Both values are allowed to be null.
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: Pair.java 1151 2025-10-01 21:32:15Z tquadrat $
- Since:
- 0.1.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.lang.Pair"
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasEntry()Returns this instance ofPairas an instance ofMap.Entry.final 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.Creates a new instance ofPairwith the right value from this one and the given new left value.right()Returns the value of therightrecord component.Creates a new instance ofPairwith the left value from this one and the given new right value.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
left
-
right
-
-
Constructor Details
-
Pair
-
-
Method Details
-
asEntry
Returns this instance of
Pairas an instance ofMap.Entry. The left value is thekey, the right value is thevalue.The method
Map.Entry.setValue(Object)is not implemented and will throw an exception when called.- Returns:
- A reference to this instance as an
Entry.
-
left
-
right
-
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
-
right
-
