Class DecoratedInvoker<T>
- Author:
- Ivan Hristov
-
Method Summary
Modifier and TypeMethodDescriptionIgnores anyRuntimeException
which comes from the preceding decorator.ignoringDecoratorExceptionsOfType
(Class<?> exceptionClass) Ignores any exception of theexceptionClass
type which comes from the preceding decorator.postDecorateWith
(T decorator) Adds a post-decorator to an already decorated fieldpreDecorateWith
(T decorator) Adds a pre-decorator to an already decorated field.Specifies that the result from the decorator should be returned.
-
Method Details
-
ignoringDecoratorExceptions
Ignores anyRuntimeException
which comes from the preceding decorator.- Returns:
- the DecoratedResultInvoker ignoring exceptions.
-
ignoringDecoratorExceptionsOfType
Ignores any exception of theexceptionClass
type which comes from the preceding decorator.- Parameters:
exceptionClass
- the exception to ignore - usually a checked exception of decorator method- Returns:
- the DecoratedResultInvoker ignoring given exception type.
-
returningDecoratorResult
Specifies that the result from the decorator should be returned.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 aRuntimeException
is thrown while executing one of the decoratedIExampleService
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 returnedfield("fieldName").ofType(IExampleService.class).in(target) .preDecorateWith(preDecoratorService) .returningDecoratorResult();
Example 2:
The result from the postDecoratorService will be returnedfield("fieldName").ofType(IExampleService.class).in(target) .postDecorateWith(postDecoratorService) .returningDecoratorResult();
Example 3:
The result from the preDecoratorService will be returned, since it's the latest attached decorator.field("fieldName").ofType(IExampleService.class).in(target) .postDecorateWith(postDecoratorService) .returningDecoratorResult() .preDecorateWith(preDecoratorService) .returningDecoratorResult();
-
preDecorateWith
Adds a pre-decorator to an already decorated field.Note that if there are more than one pre-decorators assigned to a field they will be executed starting from the last attached decorator.
- Parameters:
decorator
- which methods be called before the same targeted object methods- Returns:
- the
DecoratedInvoker
pre decorating the target field interface with given decorator.
-
postDecorateWith
Adds a post-decorator to an already decorated fieldNote that if there are more than one post-decorators assigned to a field they will be executed starting from the first attached decorator.
- Parameters:
decorator
- which methods be called after the same targeted object methods- Returns:
- the
DecoratedInvoker
post decorating the target field interface with given decorator.
-