java.lang.Object
com.aoapps.lang.util.OptionalE<T>
An optional that is allowed to throw a checked exception.
This should not be used as a return type, use standard
Optional instead.
This is useful for specific scenarios where the methods of standard Optional do not play well with
checked exceptions.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> OptionalE<T> empty()booleanfilter(PredicateE<? super T, Ex> predicate) static <T> OptionalE<T> fromOptional(Optional<? extends T> value) Convert from standardOptional.get()inthashCode()<Ex extends Throwable>
void<Ex extends Throwable>
voidifPresentOrElse(ConsumerE<? super T, Ex> action, Runnable emptyAction) booleanisEmpty()booleanstatic <T> OptionalE<T> of(T value) static <T> OptionalE<T> ofNullable(T value) orElseThrow(Supplier<? extends X> exceptionSupplier) stream()Convert to standardOptional.toString()
-
Method Details
-
empty
- See Also:
-
of
- See Also:
-
ofNullable
- See Also:
-
fromOptional
Convert from standardOptional. -
toOptional
Convert to standardOptional. -
get
- See Also:
-
isPresent
public boolean isPresent()- See Also:
-
isEmpty
public boolean isEmpty()- See Also:
-
ifPresent
- Type Parameters:
Ex- An arbitrary exception type that may be thrown- Throws:
Ex- See Also:
-
ifPresentOrElse
public <Ex extends Throwable> void ifPresentOrElse(ConsumerE<? super T, Ex> action, Runnable emptyAction) throws Ex- Type Parameters:
Ex- An arbitrary exception type that may be thrown- Throws:
Ex- See Also:
-
filter
- Type Parameters:
Ex- An arbitrary exception type that may be thrown- Throws:
Ex- See Also:
-
map
public <U,Ex extends Throwable> OptionalE<U> map(FunctionE<? super T, ? extends U, throws ExEx> mapper) - Type Parameters:
Ex- An arbitrary exception type that may be thrown- Throws:
Ex- See Also:
-
flatMap
public <U,Ex extends Throwable> OptionalE<U> flatMap(FunctionE<? super T, ? extends Optional<? extends U>, throws ExEx> mapper) - Type Parameters:
Ex- An arbitrary exception type that may be thrown- Throws:
Ex- See Also:
-
or
public <Ex extends Throwable> OptionalE<T> or(SupplierE<? extends Optional<? extends T>, Ex> supplier) throws Ex- Type Parameters:
Ex- An arbitrary exception type that may be thrown- Throws:
Ex- See Also:
-
stream
- See Also:
-
orElse
- See Also:
-
orElseGet
- Type Parameters:
Ex- An arbitrary exception type that may be thrown- Throws:
Ex- See Also:
-
orElseThrow
- See Also:
-
orElseThrow
- Throws:
X- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
-
