Module nl.jqno.equalsverifier
Record Class Tuple<T>
java.lang.Object
java.lang.Record
nl.jqno.equalsverifier.internal.reflection.Tuple<T>
- Type Parameters:
T- The assumed type of the values.- Record Components:
red- The red value.blue- The blue value.redCopy- A shallow copy of the red value.
Container for three values of the same type: a "red" one, a "blue" one, and a shallow copy of the "red" one.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionblue()Returns the value of thebluerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.<U> Tuple<U> Returns a new Tuple with the given function applied to each element.red()Returns the value of theredrecord component.redCopy()Returns the value of theredCopyrecord component.swapBlueIfEqualToRed(Supplier<T> newBlue) Returns a new Tuple with only the blue value switched to the given value and the other values left intact if the red value equals the blue value; otherwise, returns the original tuple.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
Constructor Details
-
Method Details
-
map
Returns a new Tuple with the given function applied to each element.- Parameters:
fn- The function to apply to all values.- Returns:
- A new Tuple with the given function applied to each element.
-
swapBlueIfEqualToRed
Returns a new Tuple with only the blue value switched to the given value and the other values left intact if the red value equals the blue value; otherwise, returns the original tuple. This is useful for single-element enums, where only one value can be provided: in those cases, perhaps an alternative can be provided (e.g. an empty list) using this method.- Parameters:
newBlue- A new value for blue.- Returns:
- A new tuple with the blue value switched if red an blue are equal, or the original tuple otherwise.
-
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). -
red
Returns the value of theredrecord component.- Returns:
- the value of the
redrecord component
-
blue
Returns the value of thebluerecord component.- Returns:
- the value of the
bluerecord component
-
redCopy
Returns the value of theredCopyrecord component.- Returns:
- the value of the
redCopyrecord component
-