| Modifier and Type | Class and Description |
|---|---|
static class |
ImmutableEither.Builder<L,R>
Builds instances of type
ImmutableEither. |
| Modifier and Type | Method and Description |
|---|---|
static <L,R> ImmutableEither.Builder<L,R> |
builder()
Creates a builder for
ImmutableEither. |
static <L,R> ImmutableEither<L,R> |
copyOf(Either<L,R> instance)
Creates an immutable copy of a
Either value. |
boolean |
equals(Object another)
This instance is equal to all instances of
ImmutableEither that have equal attribute values. |
int |
hashCode()
Computes a hash code from attributes:
optLeft, optRight. |
protected Optional<L> |
optLeft() |
protected Optional<R> |
optRight() |
String |
toString()
Prints the immutable value
Either with attribute values. |
ImmutableEither<L,R> |
withOptLeft(L value)
Copy the current immutable object by setting a present value for the optional
optLeft attribute. |
ImmutableEither<L,R> |
withOptLeft(Optional<? extends L> optional)
Copy the current immutable object by setting an optional value for the
optLeft attribute. |
ImmutableEither<L,R> |
withOptRight(Optional<? extends R> optional)
Copy the current immutable object by setting an optional value for the
optRight attribute. |
ImmutableEither<L,R> |
withOptRight(R value)
Copy the current immutable object by setting a present value for the optional
optRight attribute. |
public final ImmutableEither<L,R> withOptLeft(L value)
optLeft attribute.value - The value for optLeftthis objectpublic final ImmutableEither<L,R> withOptLeft(Optional<? extends L> optional)
optLeft attribute.
A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.optional - A value for optLeftthis objectpublic final ImmutableEither<L,R> withOptRight(R value)
optRight attribute.value - The value for optRightthis objectpublic final ImmutableEither<L,R> withOptRight(Optional<? extends R> optional)
optRight attribute.
A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.optional - A value for optRightthis objectpublic boolean equals(Object another)
ImmutableEither that have equal attribute values.public int hashCode()
optLeft, optRight.public String toString()
Either with attribute values.public static <L,R> ImmutableEither<L,R> copyOf(Either<L,R> instance)
Either value.
Uses accessors to get values to initialize the new immutable instance.
If an instance is already immutable, it is returned as is.L - generic parameter LR - generic parameter Rinstance - The instance to copypublic static <L,R> ImmutableEither.Builder<L,R> builder()
ImmutableEither.
ImmutableEither.<L, R>builder()
.optLeft(L) // optional optLeft
.optRight(R) // optional optRight
.build();
L - generic parameter LR - generic parameter RCopyright © 2022. All rights reserved.