public class ThrowableCollector<T> extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
ThrowableCollector.Executable
Functional interface for an executable block of code that may throw a
Throwable. |
static interface |
ThrowableCollector.ExecutableWithResult<T>
Functional interface for an executable block of code that may throw a
Throwable. |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> ThrowableCollector<T> |
create()
Factory method for
ThrowableCollector instances creation. |
void |
execute(ThrowableCollector.Executable executable)
Execute the supplied
ThrowableCollector.Executable and collect any Throwable
thrown during the execution. |
Optional<T> |
execute(ThrowableCollector.ExecutableWithResult<T> executable) |
Optional<Throwable> |
getThrowable()
Get the first
Throwable collected by this ThrowableCollector. |
public void execute(ThrowableCollector.Executable executable)
ThrowableCollector.Executable and collect any Throwable
thrown during the execution.
If the Executable throws an unrecoverable exception
— for example, an OutOfMemoryError — this method will
rethrow it.
executable - the Executable to executepublic Optional<T> execute(ThrowableCollector.ExecutableWithResult<T> executable)
public Optional<Throwable> getThrowable()
Throwable collected by this ThrowableCollector.
If this collector is not empty, the first collected Throwable
will be returned with any additional Throwables
suppressed in the
first Throwable.
Throwable or null if this
ThrowableCollector is emptypublic static <T> ThrowableCollector<T> create()
ThrowableCollector instances creation.Copyright © 2021. All rights reserved.