|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.fest.reflect.field.DecoratedInvoker<T>
public final class DecoratedInvoker<T>
A decorated invoker allowing to ignore some exceptions or returning decorator result instead of field result.
| Method Summary | |
|---|---|
DecoratedInvoker<T> |
ignoringDecoratorExceptions()
Ignores any RuntimeException which comes from the preceding decorator. |
DecoratedInvoker<T> |
ignoringDecoratorExceptionsOfType(Class<?> exceptionClass)
Ignores any exception of the exceptionClass type which comes from the preceding decorator. |
DecoratedInvoker<T> |
postDecorateWith(T decorator)
Adds a post-decorator to an already decorated field |
DecoratedInvoker<T> |
preDecorateWith(T decorator)
Adds a pre-decorator to an already decorated field. |
DecoratedInvoker<T> |
returningDecoratorResult()
Specifies that the result from the decorator should be returned. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public DecoratedInvoker<T> ignoringDecoratorExceptions()
RuntimeException which comes from the preceding decorator.
public DecoratedInvoker<T> ignoringDecoratorExceptionsOfType(Class<?> exceptionClass)
exceptionClass type which comes from the preceding decorator.
exceptionClass - the exception to ignore - usually a checked exception of decorator method
public DecoratedInvoker<T> returningDecoratorResult()
If ignoringDecoratorExceptions() is used in
combination with this method and an exception is thrown, the default value will be returned (as defined by JLS) for
all primitives or null for all non-primitive.
Example :
If a RuntimeException is thrown while executing one of the decorated IExampleService field
methods which returns primitive boolean value, the default value false will be returned.
field("fieldName").ofType(IExampleService.class).in(target)
.postDecorateWith(postDecoratorService)
.returningDecoratorResult()
.ignoringDecoratorExceptions();
In case of several decorators attached to a field, the result from the latest will be returned.
Example 1:
The result from the preDecoratorService will be returned
field("fieldName").ofType(IExampleService.class).in(target)
.preDecorateWith(preDecoratorService)
.returningDecoratorResult();
Example 2:
field("fieldName").ofType(IExampleService.class).in(target)
.postDecorateWith(postDecoratorService)
.returningDecoratorResult();
Example 3:
field("fieldName").ofType(IExampleService.class).in(target)
.postDecorateWith(postDecoratorService)
.returningDecoratorResult()
.preDecorateWith(preDecoratorService)
.returningDecoratorResult();
public DecoratedInvoker<T> preDecorateWith(T decorator)
Note that if there are more than one pre-decorators assigned to a field they will be executed starting from the last attached decorator.
decorator - which methods be called before the same targeted object methods
DecoratedInvoker pre decorating the target field interface with given decorator.public DecoratedInvoker<T> postDecorateWith(T decorator)
Note that if there are more than one post-decorators assigned to a field they will be executed starting from the first attached decorator.
decorator - which methods be called after the same targeted object methods
DecoratedInvoker post decorating the target field interface with given decorator.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||