@FunctionalInterface
public interface Block
Similar to Runnable
, but allows throwing of checked exceptions.
Modifier and Type | Method and Description |
---|---|
default Action<java.lang.Object> |
action()
Creates an
Action from this block, where the argument is ignored. |
void |
execute()
Execute the action.
|
default <T> T |
map(Function<? super Block,? extends T> function)
Maps a block onto a new object with the provided function.
|
static Block |
noop() |
default Operation |
operation()
Deprecated.
since 1.5
|
static Block |
throwException(java.lang.Throwable throwable)
Returns an action that immediately throws the given exception.
|
default java.lang.Runnable |
toRunnable()
Converts this action to a runnable.
|
static Block noop()
void execute() throws java.lang.Exception
java.lang.Exception
- anystatic Block throwException(java.lang.Throwable throwable)
The exception is thrown via Exceptions.toException(Throwable)
throwable
- the throwable to immediately throw when the returned action is executeddefault java.lang.Runnable toRunnable()
Any thrown exceptions will be unchecked
.
@Deprecated default Operation operation()
Operation
from this block.Operation.of(Block)
default Action<java.lang.Object> action()
Action
from this block, where the argument is ignored.default <T> T map(Function<? super Block,? extends T> function)
The block is not implicitly handled and the mapping function must call execute()
if desired.
T
- the return typefunction
- the mapping function