Package jjparse.data
Record Class Product<A,B>
java.lang.Object
java.lang.Record
jjparse.data.Product<A,B>
- Type Parameters:
A- The type of the first value.B- The type of the second value.- Record Components:
first- The first or left value of thisProduct.second- The second or right value of thisProduct.
A simple representation of a
Product (or pair) as a record. This class is primarily used by the combinator
Parsing.Parser.and(jjparse.Parsing.Parser<U>) to return two values without losing the type information and to offer convenient operations
for the mapping and reduction of these two values.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.first()Returns the value of thefirstrecord component.<C> Cfold(BiFunction<A, B, C> function) final inthashCode()Returns a hash code value for this object.<C,D> Product <C, D> Maps thisProductto a new one by mapping its values using the provided functions.static <A,B> Product <A, B> of(A first, B second) A shorthand for constructing a newProduct.second()Returns the value of thesecondrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
map
Maps thisProductto a new one by mapping its values using the provided functions.- Type Parameters:
C- The target type of the first value.D- The target type of the second value.- Parameters:
first- The function that is used to map the first value of thisProduct.second- The function that is used to map the second value of thisProduct.- Returns:
- A new
Productwhose values correspond to the mapped values of thisProduct.
-
fold
- Type Parameters:
C- The type of the resulting value.- Parameters:
function- The function that is used to fold the first and second value to a new value.- Returns:
- The result of applying the provided function to this
Product's values.
-
of
A shorthand for constructing a newProduct. -
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 thefirstrecord component.- Returns:
- the value of the
firstrecord component
-
second
Returns the value of thesecondrecord component.- Returns:
- the value of the
secondrecord component
-