Class Options
java.lang.Object
io.atlassian.fugue.Options
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <A,B> Option <B> Applies an option of A to an option of a function with input type A and result type B and return an option of B.filterNone(Iterable<Option<A>> options) Filter out undefined options.static <A> Option<A> Find the first option thatisDefined, or if there aren't any, then none.static <A> Iterable<A> lift()Returns a function that will lift a function that takes an A and returns a B into a function that takes an option of A and returns an option of B.Lifts a function that takes an A and returns a B into a function that takes an option of A and returns an option of B.Lifts a predicate that takes an A into a predicate that takes an option of A.static <A,B, C> Function <BiFunction<A, B, C>, BiFunction<Option<A>, Option<B>, Option<C>>> lift2()Returns a function that will lift a function that takes an A and a B and returns a C into a function that takes an option of A and an option of B and returns an option of C.static <A,B, C> BiFunction <Option<A>, Option<B>, Option<C>> lift2(BiFunction<A, B, C> f2) Lifts a function that takes an A and a B and returns a C into a function that takes an option of A and an option of B and returns an option of C.Turn a null producing function into one that returns an option instead.toOption()Function for wrapping values in a Some or None.static <AA, A extends AA>
Option<AA> Upcasts anoptionof type A to an option of its super type AA.
-
Constructor Details
-
Options
private Options()
-
-
Method Details
-
find
Find the first option thatisDefined, or if there aren't any, then none.- Type Parameters:
A- the contained type- Parameters:
options- an Iterable of options to search through- Returns:
- the first defined option, or none if there aren't any
-
upcast
-
lift
Lifts a function that takes an A and returns a B into a function that takes an option of A and returns an option of B.- Type Parameters:
A- the input type of the original functionB- the result type of the original function- Parameters:
f- the original function to be lifted, must not be null- Returns:
- a function that takes an option of type A and returns an option of type B
- Since:
- 2.0
-
lift
Returns a function that will lift a function that takes an A and returns a B into a function that takes an option of A and returns an option of B.- Type Parameters:
A- the input type of the function that can be liftedB- the result type of the function that can be lifted- Returns:
- a function that can lift a function of input type A and result type B into Option
- Since:
- 2.0
-
lift
Lifts a predicate that takes an A into a predicate that takes an option of A.- Type Parameters:
A- the input type of the predicate- Parameters:
pred- the original predicate to be lifted, must not be null- Returns:
- a predicate that takes an option of type A
- Since:
- 2.2
-
ap
Applies an option of A to an option of a function with input type A and result type B and return an option of B.- Type Parameters:
A- the input type of the function wrapped in the option 'of'B- the result type of the function wrapped in the option 'of'- Parameters:
oa- an option of the argument to the functionof- an option of a function that takes an A and returns a B- Returns:
- an option of B
- Since:
- 2.0
-
lift2
Lifts a function that takes an A and a B and returns a C into a function that takes an option of A and an option of B and returns an option of C.- Type Parameters:
A- the input type of the first argument of the original functionB- the input type of the second argument of the original functionC- the result type of the original function- Parameters:
f2- the original function to be lifted- Returns:
- a function that takes an option of type A and an option of B and returns an option of type C
- Since:
- 2.0
-
lift2
public static <A,B, Function<BiFunction<A,C> B, lift2()C>, BiFunction<Option<A>, Option<B>, Option<C>>> Returns a function that will lift a function that takes an A and a B and returns a C into a function that takes an option of A and an option of B and returns an option of C.- Type Parameters:
A- the input type of the first argument of the function that can be liftedB- the input type of the second argument of the function that can be liftedC- the result type of the function that can be lifted- Returns:
- a function that can lift a function of input type A and B and result type C into Option
- Since:
- 2.0
-
filterNone
-
flatten
-
toOption
-
nullSafe
Turn a null producing function into one that returns an option instead.- Type Parameters:
A- input type to the function.B- output type of the function.- Parameters:
nullProducing- the function that may return null- Returns:
- a function that turns nulls into None, and wraps non-null values in Some.
- Since:
- 3.0
-