Package io.vertigo.core.lang
Record Class Tuple<A,B>
java.lang.Object
java.lang.Record
io.vertigo.core.lang.Tuple<A,B>
- Type Parameters:
A- Type of first objectB- Type of second object
Immutable Tuple with 2 objects.
Provides a way to group two values of different types in a single object.
Useful for methods that need to return multiple values.
- Author:
- pchretien
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static <A,B> Tuple <A, B> of(A val1, B val2) Creates a Tuple with two objects.final StringtoString()Returns a string representation of this record class.val1()Returns the value of theval1record component.val2()Returns the value of theval2record component.
-
Constructor Details
-
Tuple
Creates an instance of aTuplerecord class.- Parameters:
val1- the value for theval1record componentval2- the value for theval2record component
-
-
Method Details
-
of
Creates a Tuple with two objects.- Type Parameters:
A- Type of first objectB- Type of second object- Parameters:
val1- First objectval2- Second object- Returns:
- New Tuple
-
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). -
val1
Returns the value of theval1record component.- Returns:
- the value of the
val1record component
-
val2
Returns the value of theval2record component.- Returns:
- the value of the
val2record component
-