Class OptionalStep1<A>
- java.lang.Object
-
- io.atlassian.fugue.extensions.step.OptionalStep1<A>
-
- Type Parameters:
A- The type of the first defined value
public final class OptionalStep1<A> extends java.lang.ObjectThe first step of theOptionaltype.This class is not intended to be contructed manually, and should only be used as part of a
Stepschain, started bySteps.begin(Optional)- Since:
- 4.7.0
- See Also:
for usage examples,Optional
-
-
Constructor Summary
Constructors Constructor Description OptionalStep1(java.util.Optional<A> optional1)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OptionalStep1<A>filter(java.util.function.Predicate<? super A> predicate)Apply the provided predicate with the previous step results.<B> OptionalStep2<A,B>then(java.util.function.Function<? super A,java.util.Optional<B>> functor)Apply the provided function with the previous Step results.<B> OptionalStep2<A,B>then(java.util.function.Supplier<java.util.Optional<B>> supplier)Apply the provided supplier with the previous Step results.<Z> java.util.Optional<Z>yield(java.util.function.Function<? super A,Z> functor)Terminating step expression, that will provide the previous steps to this function and return the result as aof
-
-
-
Field Detail
-
optional1
private final java.util.Optional<A> optional1
-
-
Constructor Detail
-
OptionalStep1
OptionalStep1(java.util.Optional<A> optional1)
-
-
Method Detail
-
then
public <B> OptionalStep2<A,B> then(java.util.function.Function<? super A,java.util.Optional<B>> functor)
Apply the provided function with the previous Step results.Internally this will perform a
Optional.flatMap(Function)and the result will become the next step value.- Type Parameters:
B- The right hand side type of the next step result- Parameters:
functor- The functor to be applied as a flatMap with the previous step- Returns:
- The next step class
-
then
public <B> OptionalStep2<A,B> then(java.util.function.Supplier<java.util.Optional<B>> supplier)
Apply the provided supplier with the previous Step results.Internally this will perform a
Optional.flatMap(Function)and the supplier will become the next step value.This is different to
then(Function)in that the previous step results are not provided for the new step evaluation.- Type Parameters:
B- The type of the next step result- Parameters:
supplier- The supplier to provide the result of the flatMap with the previous step.- Returns:
- The next step class
-
filter
public OptionalStep1<A> filter(java.util.function.Predicate<? super A> predicate)
Apply the provided predicate with the previous step results.- Parameters:
predicate- The check that must be satisfied by contained values- Returns:
- This step class with either the same last step value, or changed to empty
-
yield
public <Z> java.util.Optional<Z> yield(java.util.function.Function<? super A,Z> functor)
Terminating step expression, that will provide the previous steps to this function and return the result as aof- Type Parameters:
Z- The type for the returned result- Parameters:
functor- The yield function to map on previous values- Returns:
- An Optional containing this result or empty
-
-