L
- the type of LeftR
- the type of Right@Public @TypeInfo(value=EitherTypeInfoFactory.class) public abstract class Either<L,R> extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Either.Left<L,R>
A left value of
Either |
static class |
Either.Right<L,R>
A right value of
Either |
Constructor and Description |
---|
Either() |
Modifier and Type | Method and Description |
---|---|
boolean |
isLeft() |
boolean |
isRight() |
abstract L |
left()
Retrieve the Left value of Either.
|
static <L,R> Either<L,R> |
Left(L value)
Create a Left value of Either
|
static <L,R> Either.Left<L,R> |
obtainLeft(Either<L,R> input,
TypeSerializer<L> leftSerializer)
Utility function for
EitherSerializer to support object reuse. |
static <L,R> Either.Right<L,R> |
obtainRight(Either<L,R> input,
TypeSerializer<R> rightSerializer)
Utility function for
EitherSerializer to support object reuse. |
abstract R |
right()
Retrieve the Right value of Either.
|
static <L,R> Either<L,R> |
Right(R value)
Create a Right value of Either
|
public static <L,R> Either<L,R> Left(L value)
public static <L,R> Either<L,R> Right(R value)
public abstract L left() throws IllegalStateException
IllegalStateException
- if called on a Rightpublic abstract R right() throws IllegalStateException
IllegalStateException
- if called on a Leftpublic final boolean isLeft()
public final boolean isRight()
@Internal public static <L,R> Either.Left<L,R> obtainLeft(Either<L,R> input, TypeSerializer<L> leftSerializer)
EitherSerializer
to support object reuse.
To support object reuse both subclasses of Either contain a reference to an instance of the other type. This method provides access to and initializes the cross-reference.
L
- the type of LeftR
- the type of Rightinput
- container for Left or Right valueleftSerializer
- for creating an instance of the left type@Internal public static <L,R> Either.Right<L,R> obtainRight(Either<L,R> input, TypeSerializer<R> rightSerializer)
EitherSerializer
to support object reuse.
To support object reuse both subclasses of Either contain a reference to an instance of the other type. This method provides access to and initializes the cross-reference.
L
- the type of LeftR
- the type of Rightinput
- container for Left or Right valuerightSerializer
- for creating an instance of the right typeCopyright © 2014–2024 The Apache Software Foundation. All rights reserved.