Package org.apache.flink.types
Class Either<L,R>
- java.lang.Object
-
- org.apache.flink.types.Either<L,R>
-
- Type Parameters:
L- the type of LeftR- the type of Right
- Direct Known Subclasses:
Either.Left,Either.Right
@Public @TypeInfo(EitherTypeInfoFactory.class) public abstract class Either<L,R> extends Object
This type represents a value of one two possible types, Left or Right (a disjoint union), inspired by Scala's Either type.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEither.Left<L,R>A left value ofEitherstatic classEither.Right<L,R>A right value ofEither
-
Constructor Summary
Constructors Constructor Description Either()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanisLeft()booleanisRight()abstract Lleft()Retrieve the Left value of Either.static <L,R>
Either<L,R>Left(L value)Create a Left value of Eitherstatic <L,R>
Either.Left<L,R>obtainLeft(Either<L,R> input, TypeSerializer<L> leftSerializer)Utility function forEitherSerializerto support object reuse.static <L,R>
Either.Right<L,R>obtainRight(Either<L,R> input, TypeSerializer<R> rightSerializer)Utility function forEitherSerializerto support object reuse.abstract Rright()Retrieve the Right value of Either.static <L,R>
Either<L,R>Right(R value)Create a Right value of Either
-
-
-
Method Detail
-
Left
public static <L,R> Either<L,R> Left(L value)
Create a Left value of Either
-
Right
public static <L,R> Either<L,R> Right(R value)
Create a Right value of Either
-
left
public abstract L left() throws IllegalStateException
Retrieve the Left value of Either.- Returns:
- the Left value
- Throws:
IllegalStateException- if called on a Right
-
right
public abstract R right() throws IllegalStateException
Retrieve the Right value of Either.- Returns:
- the Right value
- Throws:
IllegalStateException- if called on a Left
-
isLeft
public final boolean isLeft()
- Returns:
- true if this is a Left value, false if this is a Right value
-
isRight
public final boolean isRight()
- Returns:
- true if this is a Right value, false if this is a Left value
-
obtainLeft
@Internal public static <L,R> Either.Left<L,R> obtainLeft(Either<L,R> input, TypeSerializer<L> leftSerializer)
Utility function forEitherSerializerto 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.
- Type Parameters:
L- the type of LeftR- the type of Right- Parameters:
input- container for Left or Right valueleftSerializer- for creating an instance of the left type- Returns:
- input if Left type else input's Left reference
-
obtainRight
@Internal public static <L,R> Either.Right<L,R> obtainRight(Either<L,R> input, TypeSerializer<R> rightSerializer)
Utility function forEitherSerializerto 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.
- Type Parameters:
L- the type of LeftR- the type of Right- Parameters:
input- container for Left or Right valuerightSerializer- for creating an instance of the right type- Returns:
- input if Right type else input's Right reference
-
-