Package io.dialob.program.expr.arith
Class ImmutablePair<L,R>
- java.lang.Object
-
- io.dialob.program.expr.arith.ImmutablePair<L,R>
-
- All Implemented Interfaces:
Pair<L,R>,Serializable
@ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutablePair<L,R> extends Object implements Pair<L,R>
Immutable implementation ofPair.Use the builder to create immutable instances:
ImmutablePair.builder(). Use the static factory method to create immutable instances:ImmutablePair.of().- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImmutablePair.Builder<L,R>Builds instances of typeImmutablePair.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <L,R>
ImmutablePair.Builder<L,R>builder()Creates a builder forImmutablePair.static <L,R>
ImmutablePair<L,R>copyOf(Pair<L,R> instance)Creates an immutable copy of aPairvalue.booleanequals(Object another)This instance is equal to all instances ofImmutablePairthat have equal attribute values.LgetLeft()RgetRight()inthashCode()Computes a hash code from attributes:left,right.static <L,R>
ImmutablePair<L,R>of(L left, R right)Construct a new immutablePairinstance.StringtoString()Prints the immutable valuePairwith attribute values.ImmutablePair<L,R>withLeft(L value)Copy the current immutable object by setting a value for theleftattribute.ImmutablePair<L,R>withRight(R value)Copy the current immutable object by setting a value for therightattribute.
-
-
-
Method Detail
-
getLeft
public L getLeft()
-
getRight
public R getRight()
-
withLeft
public final ImmutablePair<L,R> withLeft(L value)
Copy the current immutable object by setting a value for theleftattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for left- Returns:
- A modified copy of the
thisobject
-
withRight
public final ImmutablePair<L,R> withRight(R value)
Copy the current immutable object by setting a value for therightattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for right- Returns:
- A modified copy of the
thisobject
-
equals
public boolean equals(@Nullable Object another)This instance is equal to all instances ofImmutablePairthat have equal attribute values.
-
hashCode
public int hashCode()
Computes a hash code from attributes:left,right.
-
toString
public String toString()
Prints the immutable valuePairwith attribute values.
-
of
public static <L,R> ImmutablePair<L,R> of(L left, R right)
Construct a new immutablePairinstance.- Type Parameters:
L- generic parameter LR- generic parameter R- Parameters:
left- The value for theleftattributeright- The value for therightattribute- Returns:
- An immutable Pair instance
-
copyOf
public static <L,R> ImmutablePair<L,R> copyOf(Pair<L,R> instance)
Creates an immutable copy of aPairvalue. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Type Parameters:
L- generic parameter LR- generic parameter R- Parameters:
instance- The instance to copy- Returns:
- A copied immutable Pair instance
-
builder
public static <L,R> ImmutablePair.Builder<L,R> builder()
Creates a builder forImmutablePair.ImmutablePair.<L, R>builder() .left(L) // requiredleft.right(R) // requiredright.build();- Type Parameters:
L- generic parameter LR- generic parameter R- Returns:
- A new ImmutablePair builder
-
-