Top Inners Methods
io.github.resilience4j.core.functions

public Interface Either<L, R>

Known Direct Implementers
io.github.resilience4j.core.functions.Either.Right, io.github.resilience4j.core.functions.Either.Left
Imports
java.io.Serializable, java.util.NoSuchElementException, .Objects, java.util.function.Function

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Either.Left<
left component type
L
,
right component type
R
>

The Left version of an Either.

public static class
Either.Right<
left component type
L
,
right component type
R
>

The Right version of an Either.

Method Summary

Modifier and TypeMethod and Description
public default <
type of the folded value
U
>
U

Returns:

A value of type U
fold
(Function<? super L, ? extends U>
maps the left value if this is a Left
leftMapper
,
Function<? super R, ? extends U>
maps the right value if this is a Right
rightMapper
)

Folds either the left or the right side of this disjunction.

public R

Returns:

the right value
get
()

Gets the right value if this is a Right or throws if this is a Left.

public L

Returns:

The left value.
getLeft
()

Returns the left value.

public default R
public default boolean
public boolean

Returns:

true, if this is a Left, false otherwise
isLeft
()

Returns whether this Either is a Left.

public boolean

Returns:

true, if this is a Right, false otherwise
isRight
()

Returns whether this Either is a Right.

public static <
Type of left value.
L
,
Type of right value.
R
>
Either<L, R>

Returns:

A new Left instance.
left
(L
The value.
left
)

Constructs a Left

public default <
The new type of a Left value
U
>
Either<L, U>

Returns:

A new LeftProjection
map
(Function<? super R, ? extends U>
A mapper which takes a left value and returns a value of type U
mapper
)

Maps the left value if the projected Either is a Left.

public default <
Component type of the mapped right value
U
>
Either<U, R>

Returns:

a mapped Monad
mapLeft
(Function<? super L, ? extends U>
A mapper
leftMapper
)

Maps the value of this Either if it is a Left, performs no operation if this is a Right.

public static <
Type of left value.
L
,
Type of right value.
R
>
Either<L, R>

Returns:

A new Right instance.
right
(R
The value.
right
)

Constructs a Right

public default Either<R, L>

Returns:

a new Either
swap
()

Converts a Left to a Right vice versa by wrapping the value in a new type.

Method Detail

foldback to summary
public default <U> U fold(Function<? super L, ? extends U> leftMapper, Function<? super R, ? extends U> rightMapper)

Folds either the left or the right side of this disjunction.

Parameters
<U>
type of the folded value
leftMapper:Function<? super L, ? extends U>

maps the left value if this is a Left

rightMapper:Function<? super R, ? extends U>

maps the right value if this is a Right

Returns:U

A value of type U

getback to summary
public R get()

Gets the right value if this is a Right or throws if this is a Left.

Returns:R

the right value

Exceptions
NoSuchElementException:
if this is a Left.
getLeftback to summary
public L getLeft()

Returns the left value.

Returns:L

The left value.

Exceptions
NoSuchElementException:
if this is a Right.
getOrNullback to summary
public default R getOrNull()
isEmptyback to summary
public default boolean isEmpty()
isLeftback to summary
public boolean isLeft()

Returns whether this Either is a Left.

Returns:boolean

true, if this is a Left, false otherwise

isRightback to summary
public boolean isRight()

Returns whether this Either is a Right.

Returns:boolean

true, if this is a Right, false otherwise

leftback to summary
public static <L, R> Either<L, R> left(L left)

Constructs a Left

Parameters
<L>
Type of left value.
<R>
Type of right value.
left:L

The value.

Returns:Either<L, R>

A new Left instance.

mapback to summary
public default <U> Either<L, U> map(Function<? super R, ? extends U> mapper)

Maps the left value if the projected Either is a Left.

Parameters
<U>
The new type of a Left value
mapper:Function<? super R, ? extends U>

A mapper which takes a left value and returns a value of type U

Returns:Either<L, U>

A new LeftProjection

Annotations
@SuppressWarnings:unchecked
mapLeftback to summary
public default <U> Either<U, R> mapLeft(Function<? super L, ? extends U> leftMapper)

Maps the value of this Either if it is a Left, performs no operation if this is a Right.

Parameters
<U>
Component type of the mapped right value
leftMapper:Function<? super L, ? extends U>

A mapper

Returns:Either<U, R>

a mapped Monad

Annotations
@SuppressWarnings:unchecked
Exceptions
NullPointerException:
if mapper is null
rightback to summary
public static <L, R> Either<L, R> right(R right)

Constructs a Right

Parameters
<L>
Type of left value.
<R>
Type of right value.
right:R

The value.

Returns:Either<L, R>

A new Right instance.

swapback to summary
public default Either<R, L> swap()

Converts a Left to a Right vice versa by wrapping the value in a new type.

Returns:Either<R, L>

a new Either

io.github.resilience4j.core.functions back to summary

public final Class Either.Left<L, R>

extends Object
implements Either<L, R>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, io.github.resilience4j.core.functions.Either
Type Parameters
<L>
left component type
<R>
right component type

The Left version of an Either.

Field Summary

Modifier and TypeField and Description
private final L

Constructor Summary

AccessConstructor and Description
private
Left(L
a left value
value
)

Constructs a Left.

Method Summary

Modifier and TypeMethod and Description
public R
get()

Implements io.github.resilience4j.core.functions.Either.get.

Gets the right value if this is a Right or throws if this is a Left.

public L
public boolean
isLeft()

Implements io.github.resilience4j.core.functions.Either.isLeft.

Returns whether this Either is a Left.

public boolean
isRight()

Implements io.github.resilience4j.core.functions.Either.isRight.

Returns whether this Either is a Right.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

valueback to summary
private final L value

Constructor Detail

Leftback to summary
private Left(L value)

Constructs a Left.

Parameters
value:L

a left value

Method Detail

getback to summary
public R get()

Implements io.github.resilience4j.core.functions.Either.get.

Doc from io.github.resilience4j.core.functions.Either.get.

Gets the right value if this is a Right or throws if this is a Left.

Returns:R

the right value

Annotations
@Override
getLeftback to summary
public L getLeft()

Implements io.github.resilience4j.core.functions.Either.getLeft.

Doc from io.github.resilience4j.core.functions.Either.getLeft.

Returns the left value.

Returns:L

The left value.

Annotations
@Override
isLeftback to summary
public boolean isLeft()

Implements io.github.resilience4j.core.functions.Either.isLeft.

Doc from io.github.resilience4j.core.functions.Either.isLeft.

Returns whether this Either is a Left.

Returns:boolean

true, if this is a Left, false otherwise

Annotations
@Override
isRightback to summary
public boolean isRight()

Implements io.github.resilience4j.core.functions.Either.isRight.

Doc from io.github.resilience4j.core.functions.Either.isRight.

Returns whether this Either is a Right.

Returns:boolean

true, if this is a Right, false otherwise

Annotations
@Override