public final class DecoratedInvoker<T> extends Object
Modifier and Type | Method and Description |
---|---|
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.
|
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 methodpublic 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 methodsDecoratedInvoker
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 methodsDecoratedInvoker
post decorating the target field interface with given decorator.Copyright © 2007-2012 FEST (Fixtures for Easy Software Testing). All Rights Reserved.