Class Checked
java.lang.Object
io.atlassian.fugue.Checked
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceChecked.Function<A, B, E extends Exception>Represents aChecked.Functionthat may throw an exception.static interfaceChecked.Supplier<A, E extends Exception>Represents aChecked.Supplierthat may throw an exception. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondelay(Checked.Supplier<A, E> s) Create a new delayed Try representing a delayed evaluation of a potentially exception throwing operation.delayedLift(Checked.Function<A, B, E> f) Lifts a function that potentially throws into a function that either returns a delayed Try, which, when evaluated, returns a Success of the result or a failure containing the thrown exception.lift(Checked.Function<A, B, E> f) Lifts a function that potentially throws into a function that either returns a Success of the value or a failure containing the thrown exception.now(Checked.Supplier<A, E> s) Create a new Try representing the result of a potentially exception throwing operation.of(Checked.Supplier<A, E> s) Deprecated.
-
Constructor Details
-
Checked
private Checked()
-
-
Method Details
-
lift
Lifts a function that potentially throws into a function that either returns a Success of the value or a failure containing the thrown exception.- Type Parameters:
A- the function argument typeB- the function return typeE- The type of exception potentially thrown- Parameters:
f- a function that can throw- Returns:
- the argument function lifted into returning a Try
-
delayedLift
Lifts a function that potentially throws into a function that either returns a delayed Try, which, when evaluated, returns a Success of the result or a failure containing the thrown exception.- Type Parameters:
A- the function argument typeB- the function return typeE- The type of exception potentially thrown- Parameters:
f- a function that can throw- Returns:
- the argument function lifted into returning a delayed Try
-
of
Deprecated.since 4.6 This is being replaced withnow(Supplier)to make it clear that the supplier is evaluated immediately. If the evaluation needs to be delayed, usedelay(Supplier).Create a new Try representing the result of a potentially exception throwing operation. If the provided supplier throws an exception this will return a failure wrapping the exception, otherwise a success of the supplied value will be returned.- Type Parameters:
A- the type of value s suppliesE- The type of exception potentially thrown- Parameters:
s- a supplier that may throw an exception- Returns:
- If s throws an exception this will return a failure wrapping the exception, otherwise a success of the supplied value.
-
now
Create a new Try representing the result of a potentially exception throwing operation. The provided supplier is evaluated immediately. If the provided supplier throws an exception this will return a failure wrapping the exception, otherwise a success of the supplied value will be returned.- Type Parameters:
A- the type of value s suppliesE- The type of exception potentially thrown- Parameters:
s- a supplier that may throw an exception- Returns:
- If s throws an exception this will return a failure wrapping the exception, otherwise a success of the supplied value.
-
delay
Create a new delayed Try representing a delayed evaluation of a potentially exception throwing operation. The provided supplier is only called when the delayed Try is evaluated. The provided supplier is called only once no matter how many times the returned delayed Try is evaluated. If the provided supplier throws an exception the evaluation of the delayed Try will return a failure wrapping the exception, otherwise a success of the supplied value will be returned.- Type Parameters:
A- the type of value s suppliesE- The type of exception potentially thrown- Parameters:
s- a supplier that may throw an exception- Returns:
- a delayed Try. If s throws an exception this, when evaluated, will return a failure wrapping the exception, otherwise a success of the supplied value.
-
now(Supplier)to make it clear that the supplier is evaluated immediately.