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 1119 2024-03-16 09:03:57Z 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 1119 2024-03-16 09:03:57Z 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 ofPair
as an instance ofMap.Entry
.final 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.Creates a new instance ofPair
with the right value from this one and the given new left value.right()
Returns the value of theright
record component.Creates a new instance ofPair
with the left value from this one and the given new right value.final String
toString()
Returns a string representation of this record class.
-
Field Details
-
Constructor Details
-
Method Details
-
asEntry
Returns this instance of
Pair
as 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
Creates a new instance ofPair
with the right value from this one and the given new left value.- Parameters:
newLeft
- The new left value; can benull
.- Returns:
- A new instance of
Pair
.
-
right
Creates a new instance ofPair
with the left value from this one and the given new right value.- Parameters:
newRight
- The new right value; can benull
.- Returns:
- A new instance of
Pair
.
-
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
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 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
-