Package nl.colorize.util.stats
Record Class Tuple<L,R>
java.lang.Object
java.lang.Record
nl.colorize.util.stats.Tuple<L,R>
- Type Parameters:
L
- Type of the first (left) element.R
- Type of the second (right) element.
Data structure that consists of two ordered values, sometimes also referred
to as a pair. Tuples are immutable and may contain
null
values.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true ifelement
is one of this tuple's elements.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.inverse()
Returns a new tuple with the inverse of this tuple's elements.left()
Returns the value of theleft
record component.<L2,
R2> Tuple <L2, R2> static <L,
R> Tuple <L, R> of
(L left, R right) Convenience factory method to create a tuple without having to specify the generic types.right()
Returns the value of theright
record component.toString()
Returns the string representation of this tuple.
-
Constructor Details
-
Tuple
Creates an instance of aTuple
record class.- Parameters:
left
- the value for theleft
record componentright
- the value for theright
record component
-
-
Method Details
-
contains
Returns true ifelement
is one of this tuple's elements. -
inverse
Returns a new tuple with the inverse of this tuple's elements. For example, the inverse of the tuple(A, B)
will return the tuple(B, A)
. -
map
-
toString
Returns the string representation of this tuple. The returned string is in the format "(X, Y)", where X and Y are determined by the string representation of the elements of this tuple. -
of
Convenience factory method to create a tuple without having to specify the generic types. -
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 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
-