I
- the type of the input exceptions.O
- the type of the assembled (output) exceptions.@NotThreadSafe public abstract class AbstractExceptionBuilder<I extends Throwable,O extends Throwable> extends Object implements ExceptionBuilder<I,O>
update(Throwable, Throwable)
and may
override post(Throwable)
.Constructor and Description |
---|
AbstractExceptionBuilder() |
Modifier and Type | Method and Description |
---|---|
void |
check()
Either returns or checks out and throws the result of the assembly in
order to enable the assembly of another output exception.
|
O |
fail(I input)
Adds
input to the assembly and checks out and returns the
result in order to enable the assembly of another exception. |
protected O |
post(O assembly)
This function gets called to post-process the given result of the
assembly after it has been checked out.
|
protected abstract O |
update(I input,
O assembly)
This function gets called to update the given
previous result of
the assembly with the given input exception. |
void |
warn(I input)
Adds
input to the assembly and either returns or checks out
and throws the result in order to enable the assembly of another output
exception. |
public final void check() throws O extends Throwable
check
in interface ExceptionBuilder<I extends Throwable,O extends Throwable>
O
- the assembled (output) exception if the client application
wants the cooperative algorithm to abort its task.O extends Throwable
post(Throwable)
public final O fail(I input)
input
to the assembly and checks out and returns the
result in order to enable the assembly of another exception.
Called to handle an exception which doesn't allow the caller to proceed with its task. The implementation must return an appropriate exception to be thrown by the cooperative algorithm. Finally, if the implementation maintains a state, it must get updated so that this instance can get reused to handle more exceptions!
fail
in interface ExceptionBuilder<I extends Throwable,O extends Throwable>
fail
in interface ExceptionHandler<I extends Throwable,O extends Throwable>
input
- the input exception to handle.update(Throwable, Throwable)
,
post(Throwable)
protected O post(O assembly)
The implementation in the class AbstractExceptionBuilder
simply
returns assembly
.
assembly
- the assembled (output) exception.protected abstract O update(I input, @CheckForNull O assembly)
previous
result of
the assembly with the given input exception.input
- the input exception to handle.assembly
- the current assembled (output) exception or null
if this is the first call to this method or the last assembly
has already been checked out.null
.public final void warn(I input)
input
to the assembly and either returns or checks out
and throws the result in order to enable the assembly of another output
exception.
Called to handle an exception which may allow the caller to
proceed with its task.
The implementation may return from the call or throw an exception of the
parameter type O
.
If the implementation maintains a state, it must get updated
so that this instance can get reused to handle more exceptions.
The implementation in the class AbstractExceptionBuilder
adds
the given exception to the assembly for subsequent rethrowing upon a
call to check()
.
warn
in interface ExceptionBuilder<I extends Throwable,O extends Throwable>
warn
in interface ExceptionHandler<I extends Throwable,O extends Throwable>
input
- the input exception to handle.update(Throwable, Throwable)
Copyright © 2012–2017 Schlichtherle IT Services. All rights reserved.