Package fr.alasdiablo.diolib.util
Record Class ImmutablePair<K,V>
java.lang.Object
java.lang.Record
fr.alasdiablo.diolib.util.ImmutablePair<K,V>
- Type Parameters:
K- Type of the first valueV- Type of the second value
Define a tuple of two values
-
Constructor Summary
ConstructorsConstructorDescriptionImmutablePair(K key, V value) Creates an instance of aImmutablePairrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck if two pairs are equalsinthashCode()Create a hash of the current pairkey()Returns the value of thekeyrecord component.static <K,V> @NotNull ImmutablePair<K, V> of(K key, V value) Static factory use to create a pairfinal StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.
-
Constructor Details
-
ImmutablePair
Creates an instance of aImmutablePairrecord class.- Parameters:
key- the value for thekeyrecord componentvalue- the value for thevaluerecord component
-
-
Method Details
-
of
@Contract("_, _ -> new") @NotNull public static <K,V> @NotNull ImmutablePair<K,V> of(K key, V value) Static factory use to create a pair- Type Parameters:
K- Type of the first valueV- Type of the second value- Parameters:
key- first valuevalue- seconde value- Returns:
- Create a pair containing two values
-
equals
Check if two pairs are equals -
hashCode
public int hashCode()Create a hash of the current 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. -
key
Returns the value of thekeyrecord component.- Returns:
- the value of the
keyrecord component
-
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-