|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface AppliesToFilter
Implementations of this interface can be specified in the @AppliesTo.
AppliesTo filters are one of the driving technologies in Qi4j. They allow you to apply fragments (Mixins, Concerns, SideEffects), often generic ones, depending on the context that they are evaluated under. This mechanism is heavily used internally in Qi4j to achieve many other features.
The starting point is the basic use of AppliesToFilter, where the @AppliesTo annotation is given an AppliesToFilter implementation as an argument, for instance at a Mixin implementation;
@AppliesTo( MyAppliesToFilter.class ) public class SomeMixin implements InvocationHandler { } public class MyAppliesToFilter implements AppliesToFilter { public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass ) { return method.getName().startsWith( "my" ); } }In the case above, the generic mixin will only be applied to the methods that that is defined by the AppliesToFilter. This is the primary way to define limits on the application of generic fragments, since especially mixins are rarely applied to all methods.
Field Summary | |
---|---|
static AppliesToFilter |
ALWAYS
This is an internal AppliesToFilter which is assigned if no other AppliesToFilters are found for a given fragment. |
Method Summary | |
---|---|
boolean |
appliesTo(Method method,
Class<?> mixin,
Class<?> compositeType,
Class<?> fragmentClass)
Check if the Fragment should be applied or not. |
Field Detail |
---|
static final AppliesToFilter ALWAYS
There is no reason for user code to use this AppliesToFilter directly, and should be perceived as an internal class in Qi4j.
Method Detail |
---|
boolean appliesTo(Method method, Class<?> mixin, Class<?> compositeType, Class<?> fragmentClass)
method
- method that is invokedmixin
- mixin implementation for the methodcompositeType
- composite typefragmentClass
- fragment that is being applies
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |