Package e.java
Interface EOr<A>
- Type Parameters:
A
- Type of the value this EOr can contain
- All Known Implementing Classes:
EOr.Failure
,EOr.Success
public interface EOr<A>
A container that can either be a Failure containing an E or Success containing a value
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final class
A failed EOrstatic final class
A successful EOr -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final E
A default E to be used when condition does not hold while filtering an EOrA successful EOr of type Unit -
Method Summary
Modifier and TypeMethodDescriptiondefault <B> EOr
<B> Provides a next EOr if this one has a value, ignoring the valuestatic <A> EOr
<A> catching
(UnsafeSupplier<A> f, Function<Throwable, E> ifFailure) Constructs an EOr from a computation that can throwerror()
Filters this EOr by value in it, if it existsFilters this EOr by value in it, if it exists, using given functiondefault <B> EOr
<B> Computes a new EOr using value in this, if it exists, with given flat mapping functionflatMapError
(Function<E, EOr<A>> f) Computes a new EOr using E in this, if it exists, with given flat mapping functiondefault <B> B
Folds this into a single value, handling both E and value conversions with given functionsAlias of `onValue`static <A> EOr
<A> from
(A a) Constructs a successful EOr containing given valuestatic <A> EOr
<A> Constructs a failed EOr containing given Estatic <A> EOr
<A> fromNullable
(A a, Supplier<E> ifNull) Constructs an EOr from a nullable valuestatic <A> EOr
<A> fromOptional
(Optional<A> a, Supplier<E> ifEmpty) Constructs an EOr from an Optional valuedefault A
Gets the value in this or falls back to given default valuedefault boolean
hasError()
default boolean
hasValue()
default <B> EOr
<B> Converts value in this, if it exists, using given mapping function to make a new EOrConverts E in this, if it exists, using given mapping function to make a new EOrPerforms a side-effect using error in this, if it existsPerforms a side-effect using value in this, if it existsProvides an alternative EOr if this one has E, ignoring the Evalue()
-
Field Details
-
unit
-
filteredError
A default E to be used when condition does not hold while filtering an EOr- See Also:
-
-
Method Details
-
hasError
default boolean hasError()- Returns:
- Whether or not this contains an E
-
hasValue
default boolean hasValue()- Returns:
- Whether or not this contains a value
-
error
-
value
-
map
-
flatMap
-
mapError
-
flatMapError
-
fold
Folds this into a single value, handling both E and value conversions with given functions- Type Parameters:
B
- Type of the desired result- Parameters:
ifFailure
- Conversion function for EifSuccess
- Conversion function for value- Returns:
- Converted result
-
getOrElse
-
orElse
-
andThen
-
onError
-
onValue
-
forEach
-
filter
Filters this EOr by value in it, if it exists, using given function- Parameters:
condition
- Filtering functionfilteredError
- E conversion function- Returns:
- This EOr of a new EOr containing an E computed by given conversion function
-
filter
-
from
-
from
Constructs a successful EOr containing given value- Type Parameters:
A
- Type of value of resulting EOr- Parameters:
a
- A value- Returns:
- A new failed EOr containing given value
-
fromNullable
-
fromOptional
-
catching
Constructs an EOr from a computation that can throw- Type Parameters:
A
- Type of value- Parameters:
f
- A computation that can throwifFailure
- An E conversion function- Returns:
- An EOr containing either computed value or an E computed by given function
-