Class ImmutablePair<L,R>

java.lang.Object
io.dialob.session.engine.program.expr.arith.ImmutablePair<L,R>
All Implemented Interfaces:
Pair<L,R>, Serializable

@Generated(from="Pair", generator="Immutables") @ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutablePair<L,R> extends Object implements Pair<L,R>
Immutable implementation of Pair.

Use the builder to create immutable instances: ImmutablePair.builder(). Use the static factory method to create immutable instances: ImmutablePair.of().

See Also:
  • Method Details

    • getLeft

      public L getLeft()
      Specified by:
      getLeft in interface Pair<L,R>
      Returns:
      The value of the left attribute
    • getRight

      public R getRight()
      Specified by:
      getRight in interface Pair<L,R>
      Returns:
      The value of the right attribute
    • withLeft

      public final ImmutablePair<L,R> withLeft(L value)
      Copy the current immutable object by setting a value for the left attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for left
      Returns:
      A modified copy or the this object
    • withRight

      public final ImmutablePair<L,R> withRight(R value)
      Copy the current immutable object by setting a value for the right attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for right
      Returns:
      A modified copy or the this object
    • equals

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutablePair that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: left, right.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value Pair with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • of

      public static <L, R> ImmutablePair<L,R> of(L left, R right)
      Construct a new immutable Pair instance.
      Type Parameters:
      L - generic parameter L
      R - generic parameter R
      Parameters:
      left - The value for the left attribute
      right - The value for the right attribute
      Returns:
      An immutable Pair instance
    • copyOf

      public static <L, R> ImmutablePair<L,R> copyOf(Pair<L,R> instance)
      Creates an immutable copy of a Pair value. 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 L
      R - 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 for ImmutablePair.
       ImmutablePair.<L, R>builder()
          .left(L) // required left
          .right(R) // required right
          .build();
       
      Type Parameters:
      L - generic parameter L
      R - generic parameter R
      Returns:
      A new ImmutablePair builder