C
- the type of the cause exceptions.X
- the type of the assembled exceptions.@NotThreadSafe public abstract class AbstractExceptionBuilder<C extends Exception,X extends Exception> extends Object implements ExceptionBuilder<C,X>
update(Exception, Exception)
and may
override post(Exception)
.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 exception.
|
X |
fail(C cause)
Adds the
cause exception to the assembly and
checks out and returns
the result
in order to enable the assembly of another exception. |
protected X |
post(X assembly)
This method is called to post-process the given result of the assembly
after it has been checked out.
|
protected abstract X |
update(C cause,
X previous)
This method is called to update the given
previous result of
the assembly with the given cause . |
void |
warn(C cause)
Adds the
cause exception to the assembly and
either returns or checks out and throws
the result
in order to enable the assembly of another exception. |
public final void check() throws X extends Exception
check
in interface ExceptionBuilder<C extends Exception,X extends Exception>
X
- the assembled exception if the implementation wants
the caller to abort its task.X extends Exception
post(Exception)
public final X fail(C cause)
cause
exception to the assembly and
checks out and returns
the result
in order to enable the assembly of another exception.
Called to handle an exceptional condition which does not allow the caller to proceed 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 be updated so that this instance can be reused to handle more exceptions!
fail
in interface ExceptionBuilder<C extends Exception,X extends Exception>
fail
in interface ExceptionHandler<C extends Exception,X extends Exception>
cause
- the exception to handle.update(Exception, Exception)
,
post(Exception)
protected X post(X assembly)
The implementation in the class AbstractExceptionBuilder
simply
returns the parameter.
assembly
- The checked out result of the exception assembly.protected abstract X update(C cause, @CheckForNull X previous)
previous
result of
the assembly with the given cause
.cause
- A(nother) cause exception to add to the assembly.previous
- The previous result of the assembly or null
if
this is the first call since the creation of this instance or the
last assembly has been checked out.null
.public final void warn(C cause)
cause
exception to the assembly and
either returns or checks out and throws
the result
in order to enable the assembly of another exception.
Called to handle an exceptional condition which
does
allow the caller to proceed its task.
The implementation may throw an exception of the parameter type
T
or return from the call.
If the implementation maintains a state, it must be updated
so that this instance can be 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<C extends Exception,X extends Exception>
warn
in interface ExceptionHandler<C extends Exception,X extends Exception>
cause
- the exception to handle.update(Exception, Exception)
Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.