Class AnnotationFilter
- java.lang.Object
-
- com.tonic.analysis.instrumentation.filter.AnnotationFilter
-
- All Implemented Interfaces:
InstrumentationFilter
public class AnnotationFilter extends Object implements InstrumentationFilter
Filter based on annotation presence.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAnnotationFilter.BuilderBuilder for AnnotationFilter instances.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AnnotationFilter.Builderbuilder()Creates a new builder.static AnnotationFilterforAnnotation(String annotationType)Creates a filter that matches methods with the given annotation.StringgetAnnotationType()booleanisCheckClass()booleanisCheckMethod()booleanisMatchPresent()booleanmatchesClass(ClassFile classFile)Checks if the given class matches this filter.booleanmatchesField(String fieldOwner, String fieldName, String fieldDescriptor)Checks if the given field matches this filter.booleanmatchesMethod(MethodEntry method)Checks if the given method matches this filter.booleanmatchesMethodCall(String owner, String name, String descriptor)Checks if the given method call matches this filter.static AnnotationFilterwithoutAnnotation(String annotationType)Creates a filter that matches methods without the given annotation.
-
-
-
Method Detail
-
getAnnotationType
public String getAnnotationType()
- Returns:
- the annotation type descriptor to match (e.g.
"Ljavax/inject/Inject;")
-
isMatchPresent
public boolean isMatchPresent()
- Returns:
- whether the filter matches when the annotation is present (false matches when absent)
-
isCheckClass
public boolean isCheckClass()
- Returns:
- whether class annotations are checked
-
isCheckMethod
public boolean isCheckMethod()
- Returns:
- whether method annotations are checked
-
matchesClass
public boolean matchesClass(ClassFile classFile)
Description copied from interface:InstrumentationFilterChecks if the given class matches this filter.- Specified by:
matchesClassin interfaceInstrumentationFilter- Parameters:
classFile- the class file to check- Returns:
- true if the class matches, false otherwise
-
matchesMethod
public boolean matchesMethod(MethodEntry method)
Description copied from interface:InstrumentationFilterChecks if the given method matches this filter.- Specified by:
matchesMethodin interfaceInstrumentationFilter- Parameters:
method- the method entry to check- Returns:
- true if the method matches, false otherwise
-
matchesField
public boolean matchesField(String fieldOwner, String fieldName, String fieldDescriptor)
Description copied from interface:InstrumentationFilterChecks if the given field matches this filter.- Specified by:
matchesFieldin interfaceInstrumentationFilter- Parameters:
fieldOwner- the class owning the field (internal name)fieldName- the field namefieldDescriptor- the field type descriptor- Returns:
- true if the field matches, false otherwise
-
matchesMethodCall
public boolean matchesMethodCall(String owner, String name, String descriptor)
Description copied from interface:InstrumentationFilterChecks if the given method call matches this filter.- Specified by:
matchesMethodCallin interfaceInstrumentationFilter- Parameters:
owner- the class being called (internal name)name- the method namedescriptor- the method descriptor- Returns:
- true if the call matches, false otherwise
-
forAnnotation
public static AnnotationFilter forAnnotation(String annotationType)
Creates a filter that matches methods with the given annotation.- Parameters:
annotationType- the annotation type descriptor- Returns:
- the filter
-
withoutAnnotation
public static AnnotationFilter withoutAnnotation(String annotationType)
Creates a filter that matches methods without the given annotation.- Parameters:
annotationType- the annotation type descriptor- Returns:
- the filter
-
builder
public static AnnotationFilter.Builder builder()
Creates a new builder.- Returns:
- a new Builder
-
-