Package org.linkki.util
Class Optionals
java.lang.Object
org.linkki.util.Optionals
Deprecated.
Utility class for
Optional.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDeprecated.CallOptional.or(Supplier)on theOptionalobject instead. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Optionals.Either<T>Deprecated.CallOptional.or(Supplier)on the object instead.static <T> voidifPresentOrElse(Optional<T> optional, Consumer<? super T> action, Runnable emptyAction) Deprecated.UseOptional.ifPresentOrElse(Consumer, Runnable)instead.static <T> Stream<T>Deprecated.CallOptional.stream()on the object instead.
-
Method Details
-
ifPresentOrElse
@Deprecated(since="2.4.0") public static <T> void ifPresentOrElse(Optional<T> optional, Consumer<? super T> action, Runnable emptyAction) Deprecated.UseOptional.ifPresentOrElse(Consumer, Runnable)instead.If a value is present in the given optional, performs the given action with the value, otherwise performs the given empty-based action.- Parameters:
optional- anOptionalaction- the action to be performed, if a value is presentemptyAction- the empty-based action to be performed, if no value is present- Throws:
NullPointerException- if a value is present and the given action is null, or no value is present and the given empty-based action is null.
-
stream
Deprecated.CallOptional.stream()on the object instead.If a value is present, returns a sequential Stream containing only that value, otherwise returns an empty Stream.API Note: This method can be used to transform a Stream of optional elements to a Stream of present value elements:
Stream<Optional<T>> os = .. Stream<T> s = os.flatMap(Optional::stream)
- Returns:
- the optional value as a Stream
-
either
Deprecated.CallOptional.or(Supplier)on the object instead.Creates anOptionals.Eitherwrapper around the givenOptionalon whichOptionals.Either.or(Supplier)can be called.
-
Optionalinstead.