@API(status=INTERNAL,
since="5.0")
public class ThrowableCollector
extends java.lang.Object
Throwable
.Modifier and Type | Field and Description |
---|---|
private java.lang.Throwable |
throwable |
Constructor and Description |
---|
ThrowableCollector() |
Modifier and Type | Method and Description |
---|---|
private void |
add(java.lang.Throwable t)
Add the supplied
Throwable to this ThrowableCollector . |
void |
assertEmpty()
Assert that this
ThrowableCollector is empty (i.e.,
has not collected any Throwables ). |
void |
execute(Executable executable)
Execute the supplied
Executable and collect any Throwable
thrown during the execution. |
java.lang.Throwable |
getThrowable()
Get the first
Throwable collected by this
ThrowableCollector . |
boolean |
isEmpty()
Determine if this
ThrowableCollector is empty (i.e.,
has not collected any Throwables ). |
boolean |
isNotEmpty()
Determine if this
ThrowableCollector is not empty (i.e.,
has collected at least one Throwable ). |
public void execute(Executable executable)
Executable
and collect any Throwable
thrown during the execution.executable
- the Executable
to executeassertEmpty()
private void add(java.lang.Throwable t)
Throwable
to this ThrowableCollector
.t
- the Throwable
to addexecute(Executable)
,
assertEmpty()
public java.lang.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 emptyisEmpty()
,
assertEmpty()
public boolean isEmpty()
ThrowableCollector
is empty (i.e.,
has not collected any Throwables
).public boolean isNotEmpty()
ThrowableCollector
is not empty (i.e.,
has collected at least one Throwable
).public void assertEmpty()
ThrowableCollector
is empty (i.e.,
has not collected any Throwables
).
If this collector is not empty, the first collected Throwable
will be thrown with any additional throwables
suppressed in the
first Throwable
. Note, however, that the Throwable
will not be wrapped. Rather, it will be
masked
as an unchecked exception.