java.lang.Object
java.lang.Record
org.klojang.util.AnyTuple2<T,U>
- Type Parameters:
T
- The type of the first componentU
- The type of the second component- Record Components:
first
- The first component of the 2-tuplesecond
- The second component of the 2-tuple
- All Implemented Interfaces:
org.klojang.check.aux.Emptyable
public record AnyTuple2<T,U> (T first, U second)
extends Record
implements org.klojang.check.aux.Emptyable
Generic 2-tuple of arbitrarily typed objects, both of which are allowed to be
null
.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.first()
Returns the value of thefirst
record component.final int
hashCode()
Returns a hash code value for this object.boolean
Returnstrue
if both components are recursively non-empty as perObjectMethods.isDeepNotEmpty(Object)
.boolean
isEmpty()
Returnstrue
if both components arenull
, otherwisefalse
.static <T,
U> AnyTuple2 <T, U> of
(T first, U second) Returns aAnyTuple2
consisting of the specified components.second()
Returns the value of thesecond
record component.toEntry()
Converts this instance to an immutableMap
entry.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
of
Returns aAnyTuple2
consisting of the specified components.- Type Parameters:
T
- The type of the first componentU
- The type of the second component- Parameters:
first
- The first component of the 2-tuplesecond
- The second component of the 2-tuple- Returns:
- A
Tuple2
instance containing the specified values
-
toEntry
Converts this instance to an immutableMap
entry.- Returns:
- an immutable
Map
entry
-
isEmpty
public boolean isEmpty()Returnstrue
if both components arenull
, otherwisefalse
.- Specified by:
isEmpty
in interfaceorg.klojang.check.aux.Emptyable
- Returns:
true
if both components arenull
-
isDeepNotEmpty
public boolean isDeepNotEmpty()Returnstrue
if both components are recursively non-empty as perObjectMethods.isDeepNotEmpty(Object)
.- Specified by:
isDeepNotEmpty
in interfaceorg.klojang.check.aux.Emptyable
- Returns:
true
if both components are recursively non-empty
-
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)
. -
first
Returns the value of thefirst
record component.- Returns:
- the value of the
first
record component
-
second
Returns the value of thesecond
record component.- Returns:
- the value of the
second
record component
-