Class ElementMatchers
ElementMatcher
s.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
A private constructor that must not be invoked. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends AnnotationDescription>
ElementMatcher.Junction<T>annotationType
(Class<? extends Annotation> type) Matches if an annotation is of a given type.static <T extends AnnotationDescription>
ElementMatcher.Junction<T>Matches if an annotation is of a given type.static <T extends AnnotationDescription>
ElementMatcher.Junction<T>annotationType
(ElementMatcher<? super TypeDescription> matcher) Matches if an annotation's type matches the supplied matcher.static <T> ElementMatcher.Junction<T>
any()
Creates a matcher that always returnstrue
.static <T extends AnnotationDescription>
ElementMatcher.Junction<T>anyOf
(Annotation... value) Creates a matcher that matches any of the given annotations asAnnotationDescription
s by theObject.equals(Object)
method.static <T> ElementMatcher.Junction<T>
Creates a matcher that matches any of the given objects by theObject.equals(Object)
method.static <T> ElementMatcher.Junction<T>
Creates a matcher that matches any of the given objects by theObject.equals(Object)
method.static <T extends MethodDescription>
ElementMatcher.Junction<T>anyOf
(Constructor<?>... value) Creates a matcher that matches any of the given constructors asMethodDescription
s by theObject.equals(Object)
method.static <T extends FieldDescription>
ElementMatcher.Junction<T>Creates a matcher that matches any of the given fields asFieldDescription
s by theObject.equals(Object)
method.static <T extends MethodDescription>
ElementMatcher.Junction<T>Creates a matcher that matches any of the given methods asMethodDescription
s by theObject.equals(Object)
method.static <T extends TypeDefinition>
ElementMatcher.Junction<T>Creates a matcher that matches any of the given types asTypeDescription
s by theObject.equals(Object)
method.static <T> ElementMatcher.Junction<T>
cached
(ElementMatcher<? super T> matcher, int evictionSize) Wraps another matcher but caches the result of previously matched elements.static <T> ElementMatcher.Junction<T>
cached
(ElementMatcher<? super T> matcher, ConcurrentMap<? super T, Boolean> map) Wraps another matcher but caches the result of previously matched elements.static <T extends MethodDescription>
ElementMatcher.Junction<T>Matches aMethodDescription
by its capability to throw a given checked exception.static <T extends MethodDescription>
ElementMatcher.Junction<T>canThrow
(TypeDescription exceptionType) Matches aMethodDescription
by its capability to throw a given checked exception.static <T extends AnnotationSource>
ElementMatcher.Junction<T>declaresAnnotation
(ElementMatcher<? super AnnotationDescription> matcher) Matches anAnnotationSource
to declare any annotation that matches the given matcher.static <T extends MethodDescription>
ElementMatcher.Junction<T>declaresException
(Class<? extends Throwable> exceptionType) Matches a method that declares the given generic exception type as a (erased) exception type.static <T extends MethodDescription>
ElementMatcher.Junction<T>declaresException
(TypeDescription exceptionType) Matches a method that declares the given generic exception type as a (erased) exception type.static <T extends TypeDefinition>
ElementMatcher.Junction<T>declaresField
(ElementMatcher<? super FieldDescription> matcher) Matches a type by another matcher that is applied on any of its declared fields.static <T extends MethodDescription>
ElementMatcher.Junction<T>declaresGenericException
(Type exceptionType) Matches a method that declares the given generic exception type.static <T extends MethodDescription>
ElementMatcher.Junction<T>declaresGenericException
(TypeDescription.Generic exceptionType) Matches a method that declares the given generic exception type.static <T extends MethodDescription>
ElementMatcher.Junction<T>declaresGenericException
(ElementMatcher<? super Iterable<? extends TypeDescription.Generic>> matcher) Matches a method's generic exception types against the provided matcher.static <T extends TypeDefinition>
ElementMatcher.Junction<T>declaresMethod
(ElementMatcher<? super MethodDescription> matcher) Matches a type by another matcher that is applied on any of its declared methods.static <T extends FieldDescription>
ElementMatcher.Junction<T>definedField
(ElementMatcher<? super FieldDescription.InDefinedShape> matcher) Matches a field in its defined shape.static <T extends MethodDescription>
ElementMatcher.Junction<T>definedMethod
(ElementMatcher<? super MethodDescription.InDefinedShape> matcher) Matches a method in its defined shape.static <T extends ParameterDescription>
ElementMatcher.Junction<T>definedParameter
(ElementMatcher<? super ParameterDescription.InDefinedShape> matcher) Matches a parameter in its defined shape.static <T extends TypeDescription.Generic>
ElementMatcher.Junction<T>Matches a generic type's erasure against the provided type.static <T extends TypeDescription.Generic>
ElementMatcher.Junction<T>erasure
(TypeDescription type) Matches a generic type's erasure against the provided type.static <T extends TypeDescription.Generic>
ElementMatcher.Junction<T>erasure
(ElementMatcher<? super TypeDescription> matcher) Converts a matcher for a type description into a matcher for the matched type's erasure.static <T extends Iterable<? extends TypeDescription.Generic>>
ElementMatcher.Junction<T>Matches an iteration of generic types' erasures against the provided types.static <T extends Iterable<? extends TypeDescription.Generic>>
ElementMatcher.Junction<T>erasures
(Iterable<? extends TypeDescription> types) Matches an iteration of generic types' erasures against the provided types.static <T extends Iterable<? extends TypeDescription.Generic>>
ElementMatcher.Junction<T>erasures
(TypeDescription... type) Matches an iteration of generic types' erasures against the provided types.static <T extends Iterable<? extends TypeDescription.Generic>>
ElementMatcher.Junction<T>erasures
(ElementMatcher<? super Iterable<? extends TypeDescription>> matcher) Applies the provided matchers to an iteration og generic types' erasures.static <T> ElementMatcher.Junction<T>
failSafe
(ElementMatcher<? super T> matcher) Wraps another matcher to assure that an element is not matched in case that the matching causes anException
.static <T extends FieldDescription>
ElementMatcher.Junction<T>Matches a field's raw type against the provided matcher.static <T extends FieldDescription>
ElementMatcher.Junction<T>fieldType
(TypeDescription fieldType) Matches a field's raw type against the provided matcher.static <T extends FieldDescription>
ElementMatcher.Junction<T>fieldType
(ElementMatcher<? super TypeDescription> matcher) Matches a field's raw type against the provided matcher.static <T extends FieldDescription>
ElementMatcher.Junction<T>genericFieldType
(Type fieldType) Matches a field's generic type against the provided matcher.static <T extends FieldDescription>
ElementMatcher.Junction<T>genericFieldType
(TypeDescription.Generic fieldType) Matches a field's generic type against the provided matcher.static <T extends FieldDescription>
ElementMatcher.Junction<T>genericFieldType
(ElementMatcher<? super TypeDescription.Generic> matcher) Matches a field's generic type against the provided matcher.static <T extends TypeDescription>
ElementMatcher.Junction<T>hasAnnotation
(ElementMatcher<? super AnnotationDescription> matcher) Matches a list of annotations by a given matcher on a type that declared these annotations or inherited them from its super classes.static <T extends ClassLoader>
ElementMatcher.Junction<T>hasChild
(ElementMatcher<? super ClassLoader> matcher) Matches all class loaders in the hierarchy of the matched class loader against a given matcher.static <T extends NamedElement.WithDescriptor>
ElementMatcher.Junction<T>hasDescriptor
(String descriptor) Matches aNamedElement.WithDescriptor
's descriptor against a given value.static <T extends TypeDescription>
ElementMatcher.Junction<T>hasGenericSuperClass
(ElementMatcher<? super TypeDescription.Generic> matcher) Matches any type description that declares a super class (but not interface) that matches the provided matcher.static <T extends TypeDescription>
ElementMatcher.Junction<T>hasGenericSuperType
(ElementMatcher<? super TypeDescription.Generic> matcher) Matches any type description that declares a super type that matches the provided matcher.static <T extends ParameterDescription>
ElementMatcher.Junction<T>hasGenericType
(ElementMatcher<? super TypeDescription.Generic> matcher) Matches a method parameter by its generic type.static <T extends MethodDescription>
ElementMatcher.Junction<T>hasMethodName
(String internalName) Matches a method against its internal name such that constructors and type initializers are matched appropriately.static <T extends MethodDescription>
ElementMatcher.Junction<T>hasParameters
(ElementMatcher<? super Iterable<? extends ParameterDescription>> matcher) Matches aMethodDescription
by validating that its parameters fulfill a given constraint.static <T extends MethodDescription>
ElementMatcher.Junction<T>Only matches method descriptions that yield the provided signature token.static <T extends TypeDescription>
ElementMatcher.Junction<T>hasSuperClass
(ElementMatcher<? super TypeDescription> matcher) Matches any type description that declares a super class (but not interface) that matches the provided matcher.static <T extends TypeDescription>
ElementMatcher.Junction<T>hasSuperType
(ElementMatcher<? super TypeDescription> matcher) Matches any type description that declares a super type that matches the provided matcher.static <T extends ParameterDescription>
ElementMatcher.Junction<T>hasType
(ElementMatcher<? super TypeDescription> matcher) Matches a parameter's type by the given matcher.static <T extends TypeDescription>
ElementMatcher.Junction<T>inheritsAnnotation
(Class<?> type) Matches any annotations by their type on a type that declared these annotations or inherited them from its super classes.static <T extends TypeDescription>
ElementMatcher.Junction<T>Matches any annotations by their type on a type that declared these annotations or inherited them from its super classes.static <T extends TypeDescription>
ElementMatcher.Junction<T>inheritsAnnotation
(ElementMatcher<? super TypeDescription> matcher) Matches any annotations by a given matcher on a type that declared these annotations or inherited them from its super classes.static <T extends AnnotationDescription>
ElementMatcher.Junction<T>is
(Annotation annotation) Exactly matches a given annotation as anAnnotationDescription
.static <T> ElementMatcher.Junction<T>
Matches the given value which can also benull
by theObject.equals(Object)
method or by a null-check.static <T extends MethodDescription>
ElementMatcher.Junction<T>is
(Constructor<?> constructor) Exactly matches a given constructor as aMethodDescription
in its defined shape.static <T extends FieldDescription>
ElementMatcher.Junction<T>Exactly matches a given field as aFieldDescription
in its defined shape.static <T extends MethodDescription>
ElementMatcher.Junction<T>Exactly matches a given method as aMethodDescription
in its defined shape.static <T extends TypeDefinition>
ElementMatcher.Junction<T>Exactly matches a given type as aTypeDescription
.static <T extends FieldDescription>
ElementMatcher.Junction<T>Exactly matches a given field as aFieldDescription
in its defined shape.static <T extends MethodDescription>
ElementMatcher.Junction<T>is
(MethodDescription.InDefinedShape method) Exactly matches a given method or constructor as aMethodDescription
in its defined shape.static <T extends ParameterDescription>
ElementMatcher.Junction<T>is
(ParameterDescription.InDefinedShape parameter) Exactly matches a given parameter as aParameterDescription
in its defined shape.static <T extends ModifierReviewable.OfAbstraction>
ElementMatcher.Junction<T>Matches aModifierReviewable.OfAbstraction
that isabstract
.static <T extends ByteCodeElement>
ElementMatcher.Junction<T>isAccessibleTo
(Class<?> type) Matches aByteCodeElement
that is accessible to a givenClass
.static <T extends ByteCodeElement>
ElementMatcher.Junction<T>Matches aByteCodeElement
that is accessible to a givenClass
.static <T extends AnnotationSource>
ElementMatcher.Junction<T>isAnnotatedWith
(Class<? extends Annotation> type) Matches anAnnotationSource
for declared annotations.static <T extends AnnotationSource>
ElementMatcher.Junction<T>Matches anAnnotationSource
for declared annotations.static <T extends AnnotationSource>
ElementMatcher.Junction<T>isAnnotatedWith
(ElementMatcher<? super TypeDescription> matcher) Matches anAnnotationSource
for declared annotations.static <T extends TypeDescription>
ElementMatcher.Junction<T>Matches aTypeDescription
that is an annotation type.static <T extends TypeDefinition>
ElementMatcher.Junction<T>isArray()
Matches a type if it is an array type.static <T extends ClassLoader>
ElementMatcher.Junction<T>Matches exactly the bootstrapClassLoader
.static <T extends ModifierReviewable.ForMethodDescription>
ElementMatcher.Junction<T>isBridge()
Matches aMethodDescription
that is a bridge.static <T extends ClassLoader>
ElementMatcher.Junction<T>isChildOf
(ClassLoader classLoader) Matches any class loader that is either the given class loader or a child of the given class loader.static <T extends MethodDescription>
ElementMatcher.Junction<T>isClone()
Only matches theObject.clone()
method, also if it was overridden.static <T extends MethodDescription>
ElementMatcher.Junction<T>Only matches method descriptions that represent aConstructor
.static <T extends ByteCodeElement>
ElementMatcher.Junction<T>isDeclaredBy
(Class<?> type) Matches aByteCodeElement
for being declared by a givenClass
.static <T extends ByteCodeElement>
ElementMatcher.Junction<T>isDeclaredBy
(TypeDescription type) Matches aByteCodeElement
for being declared by a givenTypeDescription
.static <T extends ByteCodeElement>
ElementMatcher.Junction<T>isDeclaredBy
(ElementMatcher<? super TypeDescription> matcher) Matches aByteCodeElement
for being declared by aTypeDescription
that is matched by the given matcher.static <T extends ByteCodeElement>
ElementMatcher.Junction<T>isDeclaredByGeneric
(Type type) Matches aByteCodeElement
for being declared by a given genericType
.static <T extends ByteCodeElement>
ElementMatcher.Junction<T>Matches aByteCodeElement
for being declared by a givenTypeDescription.Generic
.static <T extends ByteCodeElement>
ElementMatcher.Junction<T>isDeclaredByGeneric
(ElementMatcher<? super TypeDescription.Generic> matcher) Matches aByteCodeElement
for being declared by aTypeDescription.Generic
that is matched by the given matcher.static <T extends MethodDescription>
ElementMatcher.Junction<T>Matches a default constructor, i.e.static <T extends MethodDescription>
ElementMatcher.Junction<T>Only matches theObject.finalize()
method if it was not overridden.static <T extends MethodDescription>
ElementMatcher.Junction<T>Only matches Java 8 default methods.static <T extends ModifierReviewable.OfEnumeration>
ElementMatcher.Junction<T>isEnum()
Matches aModifierReviewable.OfEnumeration
that is anenum
or a field holding an enum.static <T extends MethodDescription>
ElementMatcher.Junction<T>isEquals()
Only matches theObject.equals(Object)
method, also if it was overridden.static <T extends ClassLoader>
ElementMatcher.Junction<T>Matches exactly the extensionClassLoader
.static <T extends ModifierReviewable>
ElementMatcher.Junction<T>isFinal()
Matches aModifierReviewable
that isfinal
.static <T extends MethodDescription>
ElementMatcher.Junction<T>Only matches theObject.finalize()
method, even if it was overridden.static <T extends MethodDescription>
ElementMatcher.Junction<T>isGenericGetter
(Type type) Matches any Java bean getter method which returns the given type.static <T extends MethodDescription>
ElementMatcher.Junction<T>Matches any Java bean getter method which returns the given type.static <T extends MethodDescription>
ElementMatcher.Junction<T>isGenericGetter
(ElementMatcher<? super TypeDescription.Generic> matcher) Matches any Java bean getter method which returns a value with a type matches the supplied matcher.static <T extends MethodDescription>
ElementMatcher.Junction<T>isGenericSetter
(Type type) Matches any Java bean setter method which takes an argument the given type.static <T extends MethodDescription>
ElementMatcher.Junction<T>Matches any Java bean setter method which takes an argument the given type.static <T extends MethodDescription>
ElementMatcher.Junction<T>isGenericSetter
(ElementMatcher<? super TypeDescription.Generic> matcher) Matches any Java bean setter method which takes an argument that matches the supplied matcher.static <T extends MethodDescription>
ElementMatcher.Junction<T>isGetter()
Matches any Java bean getter method.static <T extends MethodDescription>
ElementMatcher.Junction<T>Matches any Java bean getter method which returns the given type.static <T extends MethodDescription>
ElementMatcher.Junction<T>An element matcher that matches any getter for the given property.static <T extends MethodDescription>
ElementMatcher.Junction<T>isGetter
(TypeDescription type) Matches any Java bean getter method which returns the given type.static <T extends MethodDescription>
ElementMatcher.Junction<T>isGetter
(ElementMatcher<? super TypeDescription> matcher) Matches any Java bean getter method which returns a value with a type matches the supplied matcher.static <T extends MethodDescription>
ElementMatcher.Junction<T>Only matches theObject.hashCode()
method, also if it was overridden.static <T extends TypeDescription>
ElementMatcher.Junction<T>Matches aTypeDescription
that is an interface.static <T extends MethodDescription>
ElementMatcher.Junction<T>isMain()
Matches a Java main method as an application entry point.static <T extends ParameterDescription>
ElementMatcher.Junction<T>Matches a parameter description for amandated
parameter.static <T extends MethodDescription>
ElementMatcher.Junction<T>isMethod()
Only matches method descriptions that represent aMethod
.static <T extends NamedElement.WithOptionalName>
ElementMatcher.Junction<T>isNamed()
Matches aNamedElement.WithOptionalName
for having an explicit name.static <T extends ModifierReviewable.ForMethodDescription>
ElementMatcher.Junction<T>isNative()
Matches aMethodDescription
that isnative
.static <T extends MethodDescription>
ElementMatcher.Junction<T>isOverriddenFrom
(Class<?> type) Matches any virtual method with a signature that is compatible to a method that is declared the supplied type.static <T extends MethodDescription>
ElementMatcher.Junction<T>Matches any virtual method with a signature that is compatible to a method that is declared the supplied type.static <T extends MethodDescription>
ElementMatcher.Junction<T>isOverriddenFrom
(ElementMatcher<? super TypeDescription> matcher) Matches any virtual method with a signature that is compatible to a method that is declared by a type that matches the supplied matcher.static <T extends MethodDescription>
ElementMatcher.Junction<T>isOverriddenFromGeneric
(Type type) Matches any virtual method with a signature that is compatible to a method that is declared the supplied type.static <T extends MethodDescription>
ElementMatcher.Junction<T>Matches any virtual method with a signature that is compatible to a method that is declared the supplied type.static <T extends MethodDescription>
ElementMatcher.Junction<T>isOverriddenFromGeneric
(ElementMatcher<? super TypeDescription.Generic> matcher) Matches any virtual method with a signature that is compatible to a method that is declared by a type that matches the supplied matcher.static <T extends ModifierReviewable.OfByteCodeElement>
ElementMatcher.Junction<T>Matches aModifierReviewable
that is package-private.static <T extends ClassLoader>
ElementMatcher.Junction<T>isParentOf
(ClassLoader classLoader) Matches any class loader that is either the given class loader or a parent of the given class loader.static <T extends TypeDefinition>
ElementMatcher.Junction<T>Matches a type if it is primitive.static <T extends ModifierReviewable.OfByteCodeElement>
ElementMatcher.Junction<T>Matches aModifierReviewable
that isprivate
.static <T extends ModifierReviewable.OfByteCodeElement>
ElementMatcher.Junction<T>Matches aModifierReviewable
that isprotected
.static <T extends ModifierReviewable.OfByteCodeElement>
ElementMatcher.Junction<T>isPublic()
Matches aModifierReviewable
that ispublic
.static <T extends TypeDefinition>
ElementMatcher.Junction<T>isRecord()
Matches a type if it is a record type.static <T extends MethodDescription>
ElementMatcher.Junction<T>isSetter()
Matches any Java bean setter method.static <T extends MethodDescription>
ElementMatcher.Junction<T>Matches any Java bean setter method which takes an argument the given type.static <T extends MethodDescription>
ElementMatcher.Junction<T>An element matcher that matches any setter for the given property.static <T extends MethodDescription>
ElementMatcher.Junction<T>isSetter
(TypeDescription type) Matches any Java bean setter method which takes an argument the given type.static <T extends MethodDescription>
ElementMatcher.Junction<T>isSetter
(ElementMatcher<? super TypeDescription> matcher) Matches any Java bean setter method which takes an argument that matches the supplied matcher.static <T extends ModifierReviewable.OfByteCodeElement>
ElementMatcher.Junction<T>isStatic()
Matches aModifierReviewable
that isstatic
.static <T extends ModifierReviewable.ForMethodDescription>
ElementMatcher.Junction<T>isStrict()
Matches aMethodDescription
that isstrictfp
.static <T extends TypeDescription>
ElementMatcher.Junction<T>isSubTypeOf
(Class<?> type) Matches any type description that is a subtype of the given type.static <T extends TypeDescription>
ElementMatcher.Junction<T>isSubTypeOf
(TypeDescription type) Matches any type description that is a subtype of the given type.static <T extends TypeDescription>
ElementMatcher.Junction<T>isSuperTypeOf
(Class<?> type) Matches any type description that is a super type of the given type.static <T extends TypeDescription>
ElementMatcher.Junction<T>isSuperTypeOf
(TypeDescription type) Matches any type description that is a super type of the given type.static <T extends ModifierReviewable.ForMethodDescription>
ElementMatcher.Junction<T>Matches aMethodDescription
that issynchronized
.static <T extends ModifierReviewable>
ElementMatcher.Junction<T>Matches aModifierReviewable
that is synthetic.static <T extends ClassLoader>
ElementMatcher.Junction<T>Matches exactly the systemClassLoader
.static <T extends MethodDescription>
ElementMatcher.Junction<T>Only matches theObject.toString()
method, also if it was overridden.static <T extends FieldDescription>
ElementMatcher.Junction<T>Matches atransient
field.static <T extends MethodDescription>
ElementMatcher.Junction<T>Only matches method descriptions that represent aClass
type initializer.static <T extends ModifierReviewable.ForMethodDescription>
ElementMatcher.Junction<T>Matches aMethodDescription
that is a var-args.static <T extends TypeDefinition>
ElementMatcher.Junction<T>isVariable
(String symbol) Matches a type variable with the given name.static <T extends TypeDefinition>
ElementMatcher.Junction<T>isVariable
(ElementMatcher<? super NamedElement> matcher) Matches a type variable with the given name.static <T extends MethodDescription>
ElementMatcher.Junction<T>Matches any method that is virtual, i.e.static <T extends ByteCodeElement>
ElementMatcher.Junction<T>isVisibleTo
(Class<?> type) Matches aByteCodeElement
that is visible to a givenClass
.static <T extends ByteCodeElement>
ElementMatcher.Junction<T>isVisibleTo
(TypeDescription type) Matches aByteCodeElement
that is visible to a givenTypeDescription
.static <T extends FieldDescription>
ElementMatcher.Junction<T>Matches avolatile
field.static <T extends NamedElement>
ElementMatcher.Junction<T>nameContains
(String infix) Matches aNamedElement
for an infix of its name.static <T extends NamedElement>
ElementMatcher.Junction<T>nameContainsIgnoreCase
(String infix) Matches aNamedElement
for an infix of its name.static <T extends NamedElement>
ElementMatcher.Junction<T>Matches aNamedElement
for its exact name.static <T extends NamedElement>
ElementMatcher.Junction<T>namedIgnoreCase
(String name) Matches aNamedElement
for its name.static <T extends NamedElement>
ElementMatcher.Junction<T>namedOneOf
(String... names) Matches aNamedElement
for its membership of a set.static <T extends NamedElement>
ElementMatcher.Junction<T>nameEndsWith
(String suffix) Matches aNamedElement
for its name's suffix.static <T extends NamedElement>
ElementMatcher.Junction<T>nameEndsWithIgnoreCase
(String suffix) Matches aNamedElement
for its name's suffix.static <T extends NamedElement>
ElementMatcher.Junction<T>nameMatches
(String regex) Matches aNamedElement
name against a regular expression.static <T extends NamedElement>
ElementMatcher.Junction<T>nameStartsWith
(String prefix) Matches aNamedElement
for its name's prefix.static <T extends NamedElement>
ElementMatcher.Junction<T>nameStartsWithIgnoreCase
(String prefix) Matches aNamedElement
for its name's prefix.static <T> ElementMatcher.Junction<T>
none()
Creates a matcher that always returnsfalse
.static <T extends AnnotationDescription>
ElementMatcher.Junction<T>noneOf
(Annotation... value) Creates a matcher that matches none of the given annotations asAnnotationDescription
s by theObject.equals(Object)
method.static <T> ElementMatcher.Junction<T>
Creates a matcher that matches none of the given objects by theObject.equals(Object)
method.static <T> ElementMatcher.Junction<T>
Creates a matcher that matches none of the given objects by theObject.equals(Object)
method.static <T extends MethodDescription>
ElementMatcher.Junction<T>noneOf
(Constructor<?>... value) Creates a matcher that matches none of the given constructors asMethodDescription
s by theObject.equals(Object)
method.static <T extends FieldDescription>
ElementMatcher.Junction<T>Creates a matcher that matches none of the given methods asFieldDescription
s by theObject.equals(Object)
method.static <T extends MethodDescription>
ElementMatcher.Junction<T>Creates a matcher that matches none of the given methods asMethodDescription
s by theObject.equals(Object)
method.static <T extends TypeDefinition>
ElementMatcher.Junction<T>Creates a matcher that matches none of the given types asTypeDescription
s by theObject.equals(Object)
method.static <T> ElementMatcher.Junction<T>
not
(ElementMatcher<? super T> matcher) Inverts another matcher.static <T extends TypeDefinition>
ElementMatcher.Junction<T>ofSort
(TypeDefinition.Sort sort) Matches generic type descriptions of the given sort.static <T extends TypeDefinition>
ElementMatcher.Junction<T>ofSort
(ElementMatcher<? super TypeDefinition.Sort> matcher) Matches generic type descriptions of the given sort.static <T extends ClassLoader>
ElementMatcher.Junction<T>ofType
(ElementMatcher<? super TypeDescription> matcher) Matches a class loader's type unless it is the bootstrap class loader which is never matched.static <T extends MethodDescription>
ElementMatcher.Junction<T>MatchesMethodDescription
s that return a given erasure type.static <T extends MethodDescription>
ElementMatcher.Junction<T>returns
(TypeDescription type) MatchesMethodDescription
s that return a given erasure type.static <T extends MethodDescription>
ElementMatcher.Junction<T>returns
(ElementMatcher<? super TypeDescription> matcher) Matches a method's return type's erasure by the given matcher.static <T extends MethodDescription>
ElementMatcher.Junction<T>returnsGeneric
(Type type) MatchesMethodDescription
s that return a given generic type.static <T extends MethodDescription>
ElementMatcher.Junction<T>MatchesMethodDescription
s that returns a givenTypeDescription
.static <T extends MethodDescription>
ElementMatcher.Junction<T>returnsGeneric
(ElementMatcher<? super TypeDescription.Generic> matcher) MatchesMethodDescription
s that match a matched method's return type.static <T extends JavaModule>
ElementMatcher.Junction<T>Matches a module if it exists, i.e.static <T extends MethodDescription>
ElementMatcher.Junction<T>takesArgument
(int index, Class<?> type) MatchesMethodDescription
s that define a given generic type as a parameter at the given index.static <T extends MethodDescription>
ElementMatcher.Junction<T>takesArgument
(int index, TypeDescription type) MatchesMethodDescription
s that define a given type erasure as a parameter at the given index.static <T extends MethodDescription>
ElementMatcher.Junction<T>takesArgument
(int index, ElementMatcher<? super TypeDescription> matcher) MatchesMethodDescription
s that define a type erasure as a parameter at the given index that matches the supplied matcher.static <T extends MethodDescription>
ElementMatcher.Junction<T>takesArguments
(int length) Matches aMethodDescription
by the number of its parameters.static <T extends MethodDescription>
ElementMatcher.Junction<T>takesArguments
(Class<?>... type) Matches a method description that takes the provided raw arguments.static <T extends MethodDescription>
ElementMatcher.Junction<T>takesArguments
(Iterable<? extends TypeDescription> types) Matches a method description that takes the provided raw arguments.static <T extends MethodDescription>
ElementMatcher.Junction<T>takesArguments
(TypeDescription... type) Matches a method description that takes the provided raw arguments.static <T extends MethodDescription>
ElementMatcher.Junction<T>takesArguments
(ElementMatcher<? super Iterable<? extends TypeDescription>> matchers) Matches aMethodDescription
by applying an iterable collection of element matcher on any parameter'sTypeDescription
.static <T extends MethodDescription>
ElementMatcher.Junction<T>takesGenericArgument
(int index, Type type) MatchesMethodDescription
s that define a given generic type as a parameter at the given index.static <T extends MethodDescription>
ElementMatcher.Junction<T>takesGenericArgument
(int index, TypeDescription.Generic type) MatchesMethodDescription
s that define a given generic type as a parameter at the given index.static <T extends MethodDescription>
ElementMatcher.Junction<T>takesGenericArgument
(int index, ElementMatcher<? super TypeDescription.Generic> matcher) MatchesMethodDescription
s that define a given generic type as a parameter at the given index.static <T extends MethodDescription>
ElementMatcher.Junction<T>takesGenericArguments
(Type... type) Matches a method description that takes the provided generic arguments.static <T extends MethodDescription>
ElementMatcher.Junction<T>takesGenericArguments
(List<? extends TypeDefinition> types) Matches a method description that takes the provided generic arguments.static <T extends MethodDescription>
ElementMatcher.Junction<T>takesGenericArguments
(TypeDefinition... type) Matches a method description that takes the provided generic arguments.static <T extends MethodDescription>
ElementMatcher.Junction<T>takesGenericArguments
(ElementMatcher<? super Iterable<? extends TypeDescription.Generic>> matchers) Matches aMethodDescription
by applying an iterable collection of element matcher on any parameter'sTypeDescription.Generic
.static <T extends MethodDescription>
ElementMatcher.Junction<T>Matches aMethodDescription
with no parameters.static <T extends AnnotationDescription>
ElementMatcher.Junction<T>targetsElement
(ElementType elementType) Matches if an annotation can target a given element type.static <T> ElementMatcher.Junction<Iterable<? extends T>>
whereAny
(ElementMatcher<? super T> matcher) Matches an iterable by assuring that at least one element of the iterable collection matches the provided matcher.static <T> ElementMatcher.Junction<Iterable<? extends T>>
whereNone
(ElementMatcher<? super T> matcher) Matches an iterable by assuring that no element of the iterable collection matches the provided matcher.
-
Constructor Details
-
ElementMatchers
private ElementMatchers()A private constructor that must not be invoked.
-
-
Method Details
-
failSafe
Wraps another matcher to assure that an element is not matched in case that the matching causes anException
.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The element matcher that potentially throws an exception.- Returns:
- A matcher that returns
false
in case that the given matcher throws an exception.
-
cached
public static <T> ElementMatcher.Junction<T> cached(ElementMatcher<? super T> matcher, ConcurrentMap<? super T, Boolean> map) Wraps another matcher but caches the result of previously matched elements. Caching can be important if a matcher requires expensive calculations.
Warning: The supplied map can however introduce a memory leak as the matched elements are stored within the map. It is therefore important to dereference this matcher at some point or to regularly evict entries from the supplied map.
- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The actual matcher for which the results are cached.map
- The map for storing results of previously matched elements.- Returns:
- A matcher that stores the results of a previous matching in the supplied map.
-
cached
public static <T> ElementMatcher.Junction<T> cached(ElementMatcher<? super T> matcher, int evictionSize) Wraps another matcher but caches the result of previously matched elements. Caching can be important if a matcher requires expensive calculations.
Warning: The cache will hold
evictionSize
elements and evict a random element once the cache contains more than the specified amount of elements. Cached elements are referenced strongly and might cause a memory leak if instance are of a significant size. Usingcached(ElementMatcher, ConcurrentMap)
allows for explicit control over cache eviction.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The actual matcher for which the results are cached.evictionSize
- The maximum amount of elements that are stored in the cache. Must be a positive number.- Returns:
- A matcher that stores the results of a previous matching in the supplied map.
-
is
Matches the given value which can also benull
by theObject.equals(Object)
method or by a null-check.- Type Parameters:
T
- The type of the matched object.- Parameters:
value
- The value that is to be matched.- Returns:
- A matcher that matches an exact value.
-
is
Exactly matches a given field as aFieldDescription
in its defined shape.- Type Parameters:
T
- The type of the matched object.- Parameters:
field
- The field to match by its description- Returns:
- An element matcher that exactly matches the given field in its defined shape.
-
is
public static <T extends FieldDescription> ElementMatcher.Junction<T> is(FieldDescription.InDefinedShape field) Exactly matches a given field as aFieldDescription
in its defined shape.- Type Parameters:
T
- The type of the matched object.- Parameters:
field
- The field to match by its description- Returns:
- An element matcher that exactly matches the given field in its defined shape.
-
definedField
public static <T extends FieldDescription> ElementMatcher.Junction<T> definedField(ElementMatcher<? super FieldDescription.InDefinedShape> matcher) Matches a field in its defined shape.- Type Parameters:
T
- The matched object's type.- Parameters:
matcher
- The matcher to apply to the matched field's defined shape.- Returns:
- A matcher that matches a matched field's defined shape.
-
is
Exactly matches a given method as aMethodDescription
in its defined shape.- Type Parameters:
T
- The type of the matched object.- Parameters:
method
- The method to match by its description- Returns:
- An element matcher that exactly matches the given method in its defined shape.
-
is
public static <T extends MethodDescription> ElementMatcher.Junction<T> is(Constructor<?> constructor) Exactly matches a given constructor as aMethodDescription
in its defined shape.- Type Parameters:
T
- The type of the matched object.- Parameters:
constructor
- The constructor to match by its description- Returns:
- An element matcher that exactly matches the given constructor in its defined shape.
-
is
public static <T extends MethodDescription> ElementMatcher.Junction<T> is(MethodDescription.InDefinedShape method) Exactly matches a given method or constructor as aMethodDescription
in its defined shape.- Type Parameters:
T
- The type of the matched object.- Parameters:
method
- The method to match by its description- Returns:
- An element matcher that exactly matches the given method or constructor in its defined shape.
-
definedMethod
public static <T extends MethodDescription> ElementMatcher.Junction<T> definedMethod(ElementMatcher<? super MethodDescription.InDefinedShape> matcher) Matches a method in its defined shape.- Type Parameters:
T
- The matched object's type.- Parameters:
matcher
- The matcher to apply to the matched method's defined shape.- Returns:
- A matcher that matches a matched method's defined shape.
-
is
public static <T extends ParameterDescription> ElementMatcher.Junction<T> is(ParameterDescription.InDefinedShape parameter) Exactly matches a given parameter as aParameterDescription
in its defined shape.- Type Parameters:
T
- The type of the matched object.- Parameters:
parameter
- The parameter to match by its description- Returns:
- An element matcher that exactly matches the given parameter in its defined shape.
-
definedParameter
public static <T extends ParameterDescription> ElementMatcher.Junction<T> definedParameter(ElementMatcher<? super ParameterDescription.InDefinedShape> matcher) Matches a parameter in its defined shape.- Type Parameters:
T
- The matched object's type.- Parameters:
matcher
- The matcher to apply to the matched parameter's defined shape.- Returns:
- A matcher that matches a matched parameter's defined shape.
-
hasType
public static <T extends ParameterDescription> ElementMatcher.Junction<T> hasType(ElementMatcher<? super TypeDescription> matcher) Matches a parameter's type by the given matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher to apply to the parameter's type.- Returns:
- A matcher that matches a parameter's type by the given matcher.
-
hasGenericType
public static <T extends ParameterDescription> ElementMatcher.Junction<T> hasGenericType(ElementMatcher<? super TypeDescription.Generic> matcher) Matches a method parameter by its generic type.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher to apply to a parameter's generic type.- Returns:
- A matcher that matches the matched parameter's generic type.
-
isMandated
Matches a parameter description for amandated
parameter.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a
mandated
parameter.
-
is
Exactly matches a given type as aTypeDescription
.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type to match by its description- Returns:
- An element matcher that exactly matches the given type.
-
is
public static <T extends AnnotationDescription> ElementMatcher.Junction<T> is(Annotation annotation) Exactly matches a given annotation as anAnnotationDescription
.- Type Parameters:
T
- The type of the matched object.- Parameters:
annotation
- The annotation to match by its description.- Returns:
- An element matcher that exactly matches the given annotation.
-
not
Inverts another matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher to invert.- Returns:
- An inverted version of the given
matcher
.
-
any
Creates a matcher that always returnstrue
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that matches anything.
-
none
Creates a matcher that always returnsfalse
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that matches nothing.
-
anyOf
Creates a matcher that matches any of the given objects by the
Object.equals(Object)
method. None of the values must benull
.Important: This method cannot be used interchangeably with any of its overloaded versions which also apply a type conversion.
- Type Parameters:
T
- The type of the matched object.- Parameters:
value
- The input values to be compared against.- Returns:
- A matcher that checks for the equality with any of the given objects.
-
anyOf
Creates a matcher that matches any of the given objects by the
Object.equals(Object)
method. None of the values must benull
.Important: This method cannot be used interchangeably with any of the overloaded versions of
anyOf(Object...)
which also apply a type conversion.- Type Parameters:
T
- The type of the matched object.- Parameters:
values
- The input values to be compared against.- Returns:
- A matcher that checks for the equality with any of the given objects.
-
anyOf
Creates a matcher that matches any of the given types asTypeDescription
s by theObject.equals(Object)
method. None of the values must benull
.- Type Parameters:
T
- The type of the matched object.- Parameters:
value
- The input values to be compared against.- Returns:
- A matcher that checks for the equality with any of the given objects.
-
anyOf
public static <T extends MethodDescription> ElementMatcher.Junction<T> anyOf(Constructor<?>... value) Creates a matcher that matches any of the given constructors asMethodDescription
s by theObject.equals(Object)
method. None of the values must benull
.- Type Parameters:
T
- The type of the matched object.- Parameters:
value
- The input values to be compared against.- Returns:
- A matcher that checks for the equality with any of the given objects.
-
anyOf
Creates a matcher that matches any of the given methods asMethodDescription
s by theObject.equals(Object)
method. None of the values must benull
.- Type Parameters:
T
- The type of the matched object.- Parameters:
value
- The input values to be compared against.- Returns:
- A matcher that checks for the equality with any of the given objects.
-
anyOf
Creates a matcher that matches any of the given fields asFieldDescription
s by theObject.equals(Object)
method. None of the values must benull
.- Type Parameters:
T
- The type of the matched object.- Parameters:
value
- The input values to be compared against.- Returns:
- A matcher that checks for the equality with any of the given objects.
-
anyOf
public static <T extends AnnotationDescription> ElementMatcher.Junction<T> anyOf(Annotation... value) Creates a matcher that matches any of the given annotations asAnnotationDescription
s by theObject.equals(Object)
method. None of the values must benull
.- Type Parameters:
T
- The type of the matched object.- Parameters:
value
- The input values to be compared against.- Returns:
- A matcher that checks for the equality with any of the given objects.
-
noneOf
Creates a matcher that matches none of the given objects by theObject.equals(Object)
method. None of the values must benull
.- Type Parameters:
T
- The type of the matched object.- Parameters:
value
- The input values to be compared against.- Returns:
- A matcher that checks for the equality with none of the given objects.
-
noneOf
Creates a matcher that matches none of the given objects by theObject.equals(Object)
method. None of the values must benull
.- Type Parameters:
T
- The type of the matched object.- Parameters:
values
- The input values to be compared against.- Returns:
- A matcher that checks for the equality with none of the given objects.
-
noneOf
Creates a matcher that matches none of the given types asTypeDescription
s by theObject.equals(Object)
method. None of the values must benull
.- Type Parameters:
T
- The type of the matched object.- Parameters:
value
- The input values to be compared against.- Returns:
- A matcher that checks for the equality with none of the given objects.
-
noneOf
public static <T extends MethodDescription> ElementMatcher.Junction<T> noneOf(Constructor<?>... value) Creates a matcher that matches none of the given constructors asMethodDescription
s by theObject.equals(Object)
method. None of the values must benull
.- Type Parameters:
T
- The type of the matched object.- Parameters:
value
- The input values to be compared against.- Returns:
- A matcher that checks for the equality with none of the given objects.
-
noneOf
Creates a matcher that matches none of the given methods asMethodDescription
s by theObject.equals(Object)
method. None of the values must benull
.- Type Parameters:
T
- The type of the matched object.- Parameters:
value
- The input values to be compared against.- Returns:
- A matcher that checks for the equality with none of the given objects.
-
noneOf
Creates a matcher that matches none of the given methods asFieldDescription
s by theObject.equals(Object)
method. None of the values must benull
.- Type Parameters:
T
- The type of the matched object.- Parameters:
value
- The input values to be compared against.- Returns:
- A matcher that checks for the equality with none of the given objects.
-
noneOf
public static <T extends AnnotationDescription> ElementMatcher.Junction<T> noneOf(Annotation... value) Creates a matcher that matches none of the given annotations asAnnotationDescription
s by theObject.equals(Object)
method. None of the values must benull
.- Type Parameters:
T
- The type of the matched object.- Parameters:
value
- The input values to be compared against.- Returns:
- A matcher that checks for the equality with any of the given objects.
-
whereAny
public static <T> ElementMatcher.Junction<Iterable<? extends T>> whereAny(ElementMatcher<? super T> matcher) Matches an iterable by assuring that at least one element of the iterable collection matches the provided matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher to apply to each element.- Returns:
- A matcher that matches an iterable if at least one element matches the provided matcher.
-
whereNone
public static <T> ElementMatcher.Junction<Iterable<? extends T>> whereNone(ElementMatcher<? super T> matcher) Matches an iterable by assuring that no element of the iterable collection matches the provided matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher to apply to each element.- Returns:
- A matcher that matches an iterable if no element matches the provided matcher.
-
erasure
Matches a generic type's erasure against the provided type. As a wildcard does not define an erasure, a runtime exception is thrown when this matcher is applied to a wildcard.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type to match a generic type's erasure against.- Returns:
- A matcher that matches a generic type's raw type against the provided non-generic type.
-
erasure
public static <T extends TypeDescription.Generic> ElementMatcher.Junction<T> erasure(TypeDescription type) Matches a generic type's erasure against the provided type. As a wildcard does not define an erasure, a runtime exception is thrown when this matcher is applied to a wildcard.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type to match a generic type's erasure against.- Returns:
- A matcher that matches a generic type's raw type against the provided non-generic type.
-
erasure
public static <T extends TypeDescription.Generic> ElementMatcher.Junction<T> erasure(ElementMatcher<? super TypeDescription> matcher) Converts a matcher for a type description into a matcher for the matched type's erasure. As a wildcard does not define an erasure, a runtime exception is thrown when this matcher is applied to a wildcard.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher to match the matched object's raw type against.- Returns:
- A type matcher for a generic type that matches the matched type's raw type against the given type description matcher.
-
erasures
public static <T extends Iterable<? extends TypeDescription.Generic>> ElementMatcher.Junction<T> erasures(Class<?>... type) Matches an iteration of generic types' erasures against the provided types. As a wildcard does not define an erasure, a runtime exception is thrown when this matcher is applied to a wildcard.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The types to match.- Returns:
- A matcher that matches an iteration of generic types' raw types against the provided non-generic types.
-
erasures
public static <T extends Iterable<? extends TypeDescription.Generic>> ElementMatcher.Junction<T> erasures(TypeDescription... type) Matches an iteration of generic types' erasures against the provided types. As a wildcard does not define an erasure, a runtime exception is thrown when this matcher is applied to a wildcard.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The types to match.- Returns:
- A matcher that matches an iteration of generic types' raw types against the provided non-generic types.
-
erasures
public static <T extends Iterable<? extends TypeDescription.Generic>> ElementMatcher.Junction<T> erasures(Iterable<? extends TypeDescription> types) Matches an iteration of generic types' erasures against the provided types. As a wildcard does not define an erasure, a runtime exception is thrown when this matcher is applied to a wildcard.- Type Parameters:
T
- The type of the matched object.- Parameters:
types
- The types to match.- Returns:
- A matcher that matches an iteration of generic types' raw types against the provided non-generic types.
-
erasures
public static <T extends Iterable<? extends TypeDescription.Generic>> ElementMatcher.Junction<T> erasures(ElementMatcher<? super Iterable<? extends TypeDescription>> matcher) Applies the provided matchers to an iteration og generic types' erasures. As a wildcard does not define an erasure, a runtime exception is thrown when this matcher is applied to a wildcard.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher to apply at the erased types.- Returns:
- A matcher that matches an iteration of generic types' raw types against the provided matcher.
-
isVariable
Matches a type variable with the given name.- Type Parameters:
T
- The type of the matched object.- Parameters:
symbol
- The name of the type variable to be match.- Returns:
- A matcher that matches type variables with the given name.
-
isVariable
public static <T extends TypeDefinition> ElementMatcher.Junction<T> isVariable(ElementMatcher<? super NamedElement> matcher) Matches a type variable with the given name.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- A matcher for the type variable's name.- Returns:
- A matcher that matches type variables with the given name.
-
named
Matches aNamedElement
for its exact name.- Type Parameters:
T
- The type of the matched object.- Parameters:
name
- The expected name.- Returns:
- An element matcher for a named element's exact name.
-
namedOneOf
Matches aNamedElement
for its membership of a set.- Type Parameters:
T
- The type of the matched object.- Parameters:
names
- The set of expected names.- Returns:
- An element matcher which matches if the element's name is found in the set.
-
namedIgnoreCase
Matches aNamedElement
for its name. The name's capitalization is ignored.- Type Parameters:
T
- The type of the matched object.- Parameters:
name
- The expected name.- Returns:
- An element matcher for a named element's name.
-
nameStartsWith
Matches aNamedElement
for its name's prefix.- Type Parameters:
T
- The type of the matched object.- Parameters:
prefix
- The expected name's prefix.- Returns:
- An element matcher for a named element's name's prefix.
-
nameStartsWithIgnoreCase
public static <T extends NamedElement> ElementMatcher.Junction<T> nameStartsWithIgnoreCase(String prefix) Matches aNamedElement
for its name's prefix. The name's capitalization is ignored.- Type Parameters:
T
- The type of the matched object.- Parameters:
prefix
- The expected name's prefix.- Returns:
- An element matcher for a named element's name's prefix.
-
nameEndsWith
Matches aNamedElement
for its name's suffix.- Type Parameters:
T
- The type of the matched object.- Parameters:
suffix
- The expected name's suffix.- Returns:
- An element matcher for a named element's name's suffix.
-
nameEndsWithIgnoreCase
public static <T extends NamedElement> ElementMatcher.Junction<T> nameEndsWithIgnoreCase(String suffix) Matches aNamedElement
for its name's suffix. The name's capitalization is ignored.- Type Parameters:
T
- The type of the matched object.- Parameters:
suffix
- The expected name's suffix.- Returns:
- An element matcher for a named element's name's suffix.
-
nameContains
Matches aNamedElement
for an infix of its name.- Type Parameters:
T
- The type of the matched object.- Parameters:
infix
- The expected infix of the name.- Returns:
- An element matcher for a named element's name's infix.
-
nameContainsIgnoreCase
public static <T extends NamedElement> ElementMatcher.Junction<T> nameContainsIgnoreCase(String infix) Matches aNamedElement
for an infix of its name. The name's capitalization is ignored.- Type Parameters:
T
- The type of the matched object.- Parameters:
infix
- The expected infix of the name.- Returns:
- An element matcher for a named element's name's infix.
-
nameMatches
Matches aNamedElement
name against a regular expression.- Type Parameters:
T
- The type of the matched object.- Parameters:
regex
- The regular expression to match the name against.- Returns:
- An element matcher for a named element's name's against the given regular expression.
-
isNamed
Matches aNamedElement.WithOptionalName
for having an explicit name.- Type Parameters:
T
- The type of the matched object.- Returns:
- An element matcher that checks if the matched optionally named element has an explicit name.
-
hasDescriptor
public static <T extends NamedElement.WithDescriptor> ElementMatcher.Junction<T> hasDescriptor(String descriptor) Matches aNamedElement.WithDescriptor
's descriptor against a given value.- Type Parameters:
T
- The type of the matched object.- Parameters:
descriptor
- The expected descriptor.- Returns:
- A matcher for the given
descriptor
.
-
isDeclaredBy
Matches aByteCodeElement
for being declared by a givenClass
. This matcher matches a declared element's raw declaring type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type that is expected to declare the matched byte code element.- Returns:
- A matcher for byte code elements being declared by the given
type
.
-
isDeclaredBy
public static <T extends ByteCodeElement> ElementMatcher.Junction<T> isDeclaredBy(TypeDescription type) Matches aByteCodeElement
for being declared by a givenTypeDescription
. This matcher matches a declared element's raw declaring type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type that is expected to declare the matched byte code element.- Returns:
- A matcher for byte code elements being declared by the given
type
.
-
isDeclaredBy
public static <T extends ByteCodeElement> ElementMatcher.Junction<T> isDeclaredBy(ElementMatcher<? super TypeDescription> matcher) Matches aByteCodeElement
for being declared by aTypeDescription
that is matched by the given matcher. This matcher matches a declared element's raw declaring type.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- A matcher for the declaring type of the matched byte code element as long as it is notnull
.- Returns:
- A matcher for byte code elements being declared by a type matched by the given
matcher
.
-
isDeclaredByGeneric
Matches aByteCodeElement
for being declared by a given genericType
.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type that is expected to declare the matched byte code element.- Returns:
- A matcher for byte code elements being declared by the given
type
.
-
isDeclaredByGeneric
public static <T extends ByteCodeElement> ElementMatcher.Junction<T> isDeclaredByGeneric(TypeDescription.Generic type) Matches aByteCodeElement
for being declared by a givenTypeDescription.Generic
.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type that is expected to declare the matched byte code element.- Returns:
- A matcher for byte code elements being declared by the given
type
.
-
isDeclaredByGeneric
public static <T extends ByteCodeElement> ElementMatcher.Junction<T> isDeclaredByGeneric(ElementMatcher<? super TypeDescription.Generic> matcher) Matches aByteCodeElement
for being declared by aTypeDescription.Generic
that is matched by the given matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- A matcher for the declaring type of the matched byte code element as long as it is notnull
.- Returns:
- A matcher for byte code elements being declared by a type matched by the given
matcher
.
-
isVisibleTo
Matches aByteCodeElement
that is visible to a givenClass
.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type that a matched byte code element is expected to be visible to.- Returns:
- A matcher for a byte code element to be visible to a given
type
.
-
isVisibleTo
public static <T extends ByteCodeElement> ElementMatcher.Junction<T> isVisibleTo(TypeDescription type) Matches aByteCodeElement
that is visible to a givenTypeDescription
.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type that a matched byte code element is expected to be visible to.- Returns:
- A matcher for a byte code element to be visible to a given
type
.
-
isAccessibleTo
Matches aByteCodeElement
that is accessible to a givenClass
.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type that a matched byte code element is expected to be accessible to.- Returns:
- A matcher for a byte code element to be accessible to a given
type
.
-
isAccessibleTo
public static <T extends ByteCodeElement> ElementMatcher.Junction<T> isAccessibleTo(TypeDescription type) Matches aByteCodeElement
that is accessible to a givenClass
.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type that a matched byte code element is expected to be accessible to.- Returns:
- A matcher for a byte code element to be accessible to a given
type
.
-
isAbstract
Matches aModifierReviewable.OfAbstraction
that isabstract
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a
abstract
modifier reviewable.
-
isEnum
Matches aModifierReviewable.OfEnumeration
that is anenum
or a field holding an enum.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for an enum.
-
isAnnotatedWith
public static <T extends AnnotationSource> ElementMatcher.Junction<T> isAnnotatedWith(Class<? extends Annotation> type) Matches anAnnotationSource
for declared annotations. This matcher does not match inherited annotations which only exist for classes. UseinheritsAnnotation(Class)
for matching inherited annotations.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The annotation type to match against.- Returns:
- A matcher that validates that an annotated element is annotated with an annotation of
type
.
-
isAnnotatedWith
public static <T extends AnnotationSource> ElementMatcher.Junction<T> isAnnotatedWith(TypeDescription type) Matches anAnnotationSource
for declared annotations. This matcher does not match inherited annotations which only exist for classes. UseinheritsAnnotation(TypeDescription)
for matching inherited annotations.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The annotation type to match against.- Returns:
- A matcher that validates that an annotated element is annotated with an annotation of
type
.
-
isAnnotatedWith
public static <T extends AnnotationSource> ElementMatcher.Junction<T> isAnnotatedWith(ElementMatcher<? super TypeDescription> matcher) Matches anAnnotationSource
for declared annotations. This matcher does not match inherited annotations which only exist for classes. UseinheritsAnnotation(net.bytebuddy.matcher.ElementMatcher)
for matching inherited annotations.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher to apply to any annotation's type found on the matched annotated element.- Returns:
- A matcher that validates that an annotated element is annotated with an annotation of a type
that matches the given
matcher
.
-
declaresAnnotation
public static <T extends AnnotationSource> ElementMatcher.Junction<T> declaresAnnotation(ElementMatcher<? super AnnotationDescription> matcher) Matches anAnnotationSource
to declare any annotation that matches the given matcher. Note that this matcher does not match inherited annotations that only exist for types. UseinheritsAnnotation(net.bytebuddy.matcher.ElementMatcher)
for matching inherited annotations.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- A matcher to apply on any declared annotation of the matched annotated element.- Returns:
- A matcher that validates that an annotated element is annotated with an annotation that matches
the given
matcher
.
-
isPublic
public static <T extends ModifierReviewable.OfByteCodeElement> ElementMatcher.Junction<T> isPublic()Matches aModifierReviewable
that ispublic
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a
public
modifier reviewable.
-
isProtected
public static <T extends ModifierReviewable.OfByteCodeElement> ElementMatcher.Junction<T> isProtected()Matches aModifierReviewable
that isprotected
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a
protected
modifier reviewable.
-
isPackagePrivate
public static <T extends ModifierReviewable.OfByteCodeElement> ElementMatcher.Junction<T> isPackagePrivate()Matches aModifierReviewable
that is package-private.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a package-private modifier reviewable.
-
isPrivate
public static <T extends ModifierReviewable.OfByteCodeElement> ElementMatcher.Junction<T> isPrivate()Matches aModifierReviewable
that isprivate
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a
private
modifier reviewable.
-
isStatic
public static <T extends ModifierReviewable.OfByteCodeElement> ElementMatcher.Junction<T> isStatic()Matches aModifierReviewable
that isstatic
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a
static
modifier reviewable.
-
isFinal
Matches aModifierReviewable
that isfinal
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a
final
modifier reviewable.
-
isSynthetic
Matches aModifierReviewable
that is synthetic.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a synthetic modifier reviewable.
-
isSynchronized
public static <T extends ModifierReviewable.ForMethodDescription> ElementMatcher.Junction<T> isSynchronized()Matches aMethodDescription
that issynchronized
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a
synchronized
method description.
-
isNative
public static <T extends ModifierReviewable.ForMethodDescription> ElementMatcher.Junction<T> isNative()Matches aMethodDescription
that isnative
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a
native
method description.
-
isStrict
public static <T extends ModifierReviewable.ForMethodDescription> ElementMatcher.Junction<T> isStrict()Matches aMethodDescription
that isstrictfp
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a
strictfp
method description.
-
isVarArgs
public static <T extends ModifierReviewable.ForMethodDescription> ElementMatcher.Junction<T> isVarArgs()Matches aMethodDescription
that is a var-args.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a var-args method description.
-
isBridge
public static <T extends ModifierReviewable.ForMethodDescription> ElementMatcher.Junction<T> isBridge()Matches aMethodDescription
that is a bridge.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a bridge method.
-
returnsGeneric
MatchesMethodDescription
s that return a given generic type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The generic type the matched method is expected to return.- Returns:
- An element matcher that matches a given generic return type for a method description.
-
returnsGeneric
public static <T extends MethodDescription> ElementMatcher.Junction<T> returnsGeneric(TypeDescription.Generic type) MatchesMethodDescription
s that returns a givenTypeDescription
.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type the matched method is expected to return.- Returns:
- An element matcher that matches a given return type for a method description.
-
returns
MatchesMethodDescription
s that return a given erasure type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The raw type the matched method is expected to return.- Returns:
- An element matcher that matches a given return type for a method description.
-
returns
public static <T extends MethodDescription> ElementMatcher.Junction<T> returns(TypeDescription type) MatchesMethodDescription
s that return a given erasure type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The raw type the matched method is expected to return.- Returns:
- An element matcher that matches a given return type for a method description.
-
returns
public static <T extends MethodDescription> ElementMatcher.Junction<T> returns(ElementMatcher<? super TypeDescription> matcher) Matches a method's return type's erasure by the given matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher to apply to a method's return type's erasure.- Returns:
- A matcher that matches the matched method's return type's erasure.
-
returnsGeneric
public static <T extends MethodDescription> ElementMatcher.Junction<T> returnsGeneric(ElementMatcher<? super TypeDescription.Generic> matcher) MatchesMethodDescription
s that match a matched method's return type.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- A matcher to apply onto a matched method's return type.- Returns:
- An element matcher that matches a given return type against another
matcher
.
-
takesGenericArgument
public static <T extends MethodDescription> ElementMatcher.Junction<T> takesGenericArgument(int index, Type type) MatchesMethodDescription
s that define a given generic type as a parameter at the given index.- Type Parameters:
T
- The type of the matched object.- Parameters:
index
- The index of the parameter.type
- The generic type the matched method is expected to define as a parameter type.- Returns:
- An element matcher that matches a given generic return type for a method description.
-
takesGenericArgument
public static <T extends MethodDescription> ElementMatcher.Junction<T> takesGenericArgument(int index, TypeDescription.Generic type) MatchesMethodDescription
s that define a given generic type as a parameter at the given index.- Type Parameters:
T
- The type of the matched object.- Parameters:
index
- The index of the parameter.type
- The generic type the matched method is expected to define as a parameter type.- Returns:
- An element matcher that matches a given generic return type for a method description.
-
takesGenericArgument
public static <T extends MethodDescription> ElementMatcher.Junction<T> takesGenericArgument(int index, ElementMatcher<? super TypeDescription.Generic> matcher) MatchesMethodDescription
s that define a given generic type as a parameter at the given index.- Type Parameters:
T
- The type of the matched object.- Parameters:
index
- The index of the parameter.matcher
- A matcher for the generic type the matched method is expected to define as a parameter type.- Returns:
- An element matcher that matches a given generic return type for a method description.
-
takesGenericArguments
public static <T extends MethodDescription> ElementMatcher.Junction<T> takesGenericArguments(Type... type) Matches a method description that takes the provided generic arguments.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The arguments to match against the matched method.- Returns:
- A method matcher that matches a method's generic parameter types against the supplied arguments.
-
takesGenericArguments
public static <T extends MethodDescription> ElementMatcher.Junction<T> takesGenericArguments(TypeDefinition... type) Matches a method description that takes the provided generic arguments.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The arguments to match against the matched method.- Returns:
- A method matcher that matches a method's generic parameter types against the supplied arguments.
-
takesGenericArguments
public static <T extends MethodDescription> ElementMatcher.Junction<T> takesGenericArguments(List<? extends TypeDefinition> types) Matches a method description that takes the provided generic arguments.- Type Parameters:
T
- The type of the matched object.- Parameters:
types
- The arguments to match against the matched method.- Returns:
- A method matcher that matches a method's generic parameter types against the supplied arguments.
-
takesGenericArguments
public static <T extends MethodDescription> ElementMatcher.Junction<T> takesGenericArguments(ElementMatcher<? super Iterable<? extends TypeDescription.Generic>> matchers) Matches aMethodDescription
by applying an iterable collection of element matcher on any parameter'sTypeDescription.Generic
.- Type Parameters:
T
- The type of the matched object.- Parameters:
matchers
- The matcher that are applied onto the parameter types of the matched method description.- Returns:
- A matcher that matches a method description by applying another element matcher onto each parameter's type.
-
takesArgument
public static <T extends MethodDescription> ElementMatcher.Junction<T> takesArgument(int index, Class<?> type) MatchesMethodDescription
s that define a given generic type as a parameter at the given index.- Type Parameters:
T
- The type of the matched object.- Parameters:
index
- The index of the parameter.type
- The erasure of the type the matched method is expected to define as a parameter type.- Returns:
- An element matcher that matches a given argument type for a method description.
-
takesArgument
public static <T extends MethodDescription> ElementMatcher.Junction<T> takesArgument(int index, TypeDescription type) MatchesMethodDescription
s that define a given type erasure as a parameter at the given index.- Type Parameters:
T
- The type of the matched object.- Parameters:
index
- The index of the parameter.type
- The erasure of the type the matched method is expected to define as a parameter type.- Returns:
- An element matcher that matches a given argument type for a method description.
-
takesArgument
public static <T extends MethodDescription> ElementMatcher.Junction<T> takesArgument(int index, ElementMatcher<? super TypeDescription> matcher) MatchesMethodDescription
s that define a type erasure as a parameter at the given index that matches the supplied matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
index
- The index of the parameter.matcher
- A matcher to apply to the argument at the specified index.- Returns:
- An element matcher that matches a given argument type for a method description.
-
takesArguments
public static <T extends MethodDescription> ElementMatcher.Junction<T> takesArguments(Class<?>... type) Matches a method description that takes the provided raw arguments.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The arguments to match against the matched method.- Returns:
- A method matcher that matches a method's raw parameter types against the supplied arguments.
-
takesArguments
public static <T extends MethodDescription> ElementMatcher.Junction<T> takesArguments(TypeDescription... type) Matches a method description that takes the provided raw arguments.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The arguments to match against the matched method.- Returns:
- A method matcher that matches a method's raw parameter types against the supplied arguments.
-
takesArguments
public static <T extends MethodDescription> ElementMatcher.Junction<T> takesArguments(Iterable<? extends TypeDescription> types) Matches a method description that takes the provided raw arguments.- Type Parameters:
T
- The type of the matched object.- Parameters:
types
- The arguments to match against the matched method.- Returns:
- A method matcher that matches a method's raw parameter types against the supplied arguments.
-
takesArguments
public static <T extends MethodDescription> ElementMatcher.Junction<T> takesArguments(ElementMatcher<? super Iterable<? extends TypeDescription>> matchers) Matches aMethodDescription
by applying an iterable collection of element matcher on any parameter'sTypeDescription
.- Type Parameters:
T
- The type of the matched object.- Parameters:
matchers
- The matcher that are applied onto the parameter types of the matched method description.- Returns:
- A matcher that matches a method description by applying another element matcher onto each parameter's type.
-
takesArguments
Matches aMethodDescription
by the number of its parameters.- Type Parameters:
T
- The type of the matched object.- Parameters:
length
- The expected length.- Returns:
- A matcher that matches a method description by the number of its parameters.
-
takesNoArguments
Matches aMethodDescription
with no parameters.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that matches a method description by the number of its parameters.
-
hasParameters
public static <T extends MethodDescription> ElementMatcher.Junction<T> hasParameters(ElementMatcher<? super Iterable<? extends ParameterDescription>> matcher) Matches aMethodDescription
by validating that its parameters fulfill a given constraint.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher to apply for validating the parameters.- Returns:
- A matcher that matches a method description's parameters against the given constraint.
-
canThrow
public static <T extends MethodDescription> ElementMatcher.Junction<T> canThrow(Class<? extends Throwable> exceptionType) Matches aMethodDescription
by its capability to throw a given checked exception. For specifying a non-checked exception, any method is matched.- Type Parameters:
T
- The type of the matched object.- Parameters:
exceptionType
- The type of the exception that should be declared by the method to be matched.- Returns:
- A matcher that matches a method description by its declaration of throwing a checked exception.
-
canThrow
public static <T extends MethodDescription> ElementMatcher.Junction<T> canThrow(TypeDescription exceptionType) Matches aMethodDescription
by its capability to throw a given checked exception. For specifying a non-checked exception, any method is matched.- Type Parameters:
T
- The type of the matched object.- Parameters:
exceptionType
- The type of the exception that should be declared by the method to be matched.- Returns:
- A matcher that matches a method description by its declaration of throwing a checked exception.
-
declaresGenericException
public static <T extends MethodDescription> ElementMatcher.Junction<T> declaresGenericException(Type exceptionType) Matches a method that declares the given generic exception type. For non-generic type, this matcher behaves identically todeclaresException(Class)
. For exceptions that are expressed as type variables, only exceptions that are represented as this type variable are matched.- Type Parameters:
T
- The type of the matched object.- Parameters:
exceptionType
- The generic exception type that is matched exactly.- Returns:
- A matcher that matches any method that exactly matches the provided generic exception.
-
declaresGenericException
public static <T extends MethodDescription> ElementMatcher.Junction<T> declaresGenericException(TypeDescription.Generic exceptionType) Matches a method that declares the given generic exception type. For non-generic type, this matcher behaves identically todeclaresException(TypeDescription)
. For exceptions that are expressed as type variables, only exceptions that are represented as this type variable are matched.- Type Parameters:
T
- The type of the matched object.- Parameters:
exceptionType
- The generic exception type that is matched exactly.- Returns:
- A matcher that matches any method that exactly matches the provided generic exception.
-
declaresException
public static <T extends MethodDescription> ElementMatcher.Junction<T> declaresException(Class<? extends Throwable> exceptionType) Matches a method that declares the given generic exception type as a (erased) exception type.- Type Parameters:
T
- The type of the matched object.- Parameters:
exceptionType
- The exception type that is matched.- Returns:
- A matcher that matches any method that exactly matches the provided exception.
-
declaresException
public static <T extends MethodDescription> ElementMatcher.Junction<T> declaresException(TypeDescription exceptionType) Matches a method that declares the given generic exception type as a (erased) exception type.- Type Parameters:
T
- The type of the matched object.- Parameters:
exceptionType
- The exception type that is matched.- Returns:
- A matcher that matches any method that exactly matches the provided exception.
-
declaresGenericException
public static <T extends MethodDescription> ElementMatcher.Junction<T> declaresGenericException(ElementMatcher<? super Iterable<? extends TypeDescription.Generic>> matcher) Matches a method's generic exception types against the provided matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The exception matcher to apply onto the matched method's generic exceptions.- Returns:
- A matcher that applies the provided matcher to a method's generic exception types.
-
isOverriddenFrom
public static <T extends MethodDescription> ElementMatcher.Junction<T> isOverriddenFrom(Class<?> type) Matches any virtual method with a signature that is compatible to a method that is declared the supplied type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The super type of interest for which to check if it declares a method with the same signature as the matched method.- Returns:
- A matcher that checks a method's signature equality for any method declared by the declaring type.
-
isOverriddenFrom
public static <T extends MethodDescription> ElementMatcher.Junction<T> isOverriddenFrom(TypeDescription type) Matches any virtual method with a signature that is compatible to a method that is declared the supplied type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The super type of interest for which to check if it declares a method with the same signature as the matched method.- Returns:
- A matcher that checks a method's signature equality for any method declared by the declaring type.
-
isOverriddenFrom
public static <T extends MethodDescription> ElementMatcher.Junction<T> isOverriddenFrom(ElementMatcher<? super TypeDescription> matcher) Matches any virtual method with a signature that is compatible to a method that is declared by a type that matches the supplied matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- A matcher for a method's declaring type that needs to be matched if that type declares a method with the same signature as the matched method.- Returns:
- A matcher that checks a method's signature equality for any method declared by the declaring type.
-
isOverriddenFromGeneric
public static <T extends MethodDescription> ElementMatcher.Junction<T> isOverriddenFromGeneric(Type type) Matches any virtual method with a signature that is compatible to a method that is declared the supplied type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The super type of interest for which to check if it declares a method with the same signature as the matched method.- Returns:
- A matcher that checks a method's signature equality for any method declared by the declaring type.
-
isOverriddenFromGeneric
public static <T extends MethodDescription> ElementMatcher.Junction<T> isOverriddenFromGeneric(TypeDescription.Generic type) Matches any virtual method with a signature that is compatible to a method that is declared the supplied type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The super type of interest for which to check if it declares a method with the same signature as the matched method.- Returns:
- A matcher that checks a method's signature equality for any method declared by the declaring type.
-
isOverriddenFromGeneric
public static <T extends MethodDescription> ElementMatcher.Junction<T> isOverriddenFromGeneric(ElementMatcher<? super TypeDescription.Generic> matcher) Matches any virtual method with a signature that is compatible to a method that is declared by a type that matches the supplied matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- A matcher for a method's declaring type that needs to be matched if that type declares a method with the same signature as the matched method.- Returns:
- A matcher that checks a method's signature equality for any method declared by the declaring type.
-
isInterface
Matches aTypeDescription
that is an interface. Annotation types are also considered interface types.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for an interface.
- See Also:
-
isAnnotation
Matches aTypeDescription
that is an annotation type.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for an annotation type.
-
isMethod
Only matches method descriptions that represent aMethod
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that only matches method descriptions that represent a Java method.
-
isConstructor
Only matches method descriptions that represent aConstructor
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that only matches method descriptions that represent a Java constructor.
-
isTypeInitializer
Only matches method descriptions that represent aClass
type initializer.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that only matches method descriptions that represent the type initializer.
-
isVirtual
Matches any method that is virtual, i.e. non-constructors that are non-static and non-private.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for virtual methods.
-
isDefaultMethod
Only matches Java 8 default methods.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that only matches Java 8 default methods.
-
isDefaultConstructor
Matches a default constructor, i.e. a constructor without arguments.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that matches a default constructor.
-
isMain
Matches a Java main method as an application entry point.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that matches a Java main method.
-
isDefaultFinalizer
Only matches theObject.finalize()
method if it was not overridden.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that only matches a non-overridden
Object.finalize()
method.
-
isFinalizer
Only matches theObject.finalize()
method, even if it was overridden.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that only matches the
Object.finalize()
method.
-
isHashCode
Only matches theObject.hashCode()
method, also if it was overridden.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that only matches the
Object.hashCode()
method.
-
isEquals
Only matches theObject.equals(Object)
method, also if it was overridden.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that only matches the
Object.equals(Object)
method.
-
isClone
Only matches theObject.clone()
method, also if it was overridden.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that only matches the
Object.clone()
method.
-
isToString
Only matches theObject.toString()
method, also if it was overridden.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that only matches the
Object.toString()
method.
-
isSetter
Matches any Java bean setter method.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that matches any setter method.
-
isSetter
An element matcher that matches any setter for the given property. When given an empty string, any setter namedset
is matched despite that such a setter is not fulfilling the Java bean naming conventions.- Type Parameters:
T
- The type of the matched object.- Parameters:
property
- The property to match a setter for.- Returns:
- A matcher that matches any setter method for the supplied property.
-
isSetter
Matches any Java bean setter method which takes an argument the given type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The required setter type.- Returns:
- A matcher that matches any setter method.
-
isGenericSetter
Matches any Java bean setter method which takes an argument the given type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The required setter type.- Returns:
- A matcher that matches any setter method.
-
isSetter
public static <T extends MethodDescription> ElementMatcher.Junction<T> isSetter(TypeDescription type) Matches any Java bean setter method which takes an argument the given type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The required setter type.- Returns:
- A matcher that matches a setter method with the specified argument type.
-
isGenericSetter
public static <T extends MethodDescription> ElementMatcher.Junction<T> isGenericSetter(TypeDescription.Generic type) Matches any Java bean setter method which takes an argument the given type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The required setter type.- Returns:
- A matcher that matches a setter method with the specified argument type.
-
isSetter
public static <T extends MethodDescription> ElementMatcher.Junction<T> isSetter(ElementMatcher<? super TypeDescription> matcher) Matches any Java bean setter method which takes an argument that matches the supplied matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- A matcher to be allied to a setter method's argument type.- Returns:
- A matcher that matches a setter method with an argument type that matches the supplied matcher.
-
isGenericSetter
public static <T extends MethodDescription> ElementMatcher.Junction<T> isGenericSetter(ElementMatcher<? super TypeDescription.Generic> matcher) Matches any Java bean setter method which takes an argument that matches the supplied matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- A matcher to be allied to a setter method's argument type.- Returns:
- A matcher that matches a setter method with an argument type that matches the supplied matcher.
-
isGetter
Matches any Java bean getter method.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that matches any getter method.
-
isGetter
An element matcher that matches any getter for the given property. When given an empty string, any getter namedget
is matched despite that such a getter is not fulfilling the Java bean naming conventions. If a getter's type isboolean
orBoolean
,is
is also accepted as a prefix.- Type Parameters:
T
- The type of the matched object.- Parameters:
property
- The property to match a getter for.- Returns:
- A matcher that matches any getter method for the supplied property.
-
isGetter
Matches any Java bean getter method which returns the given type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The required getter type.- Returns:
- A matcher that matches a getter method with the given type.
-
isGenericGetter
Matches any Java bean getter method which returns the given type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The required getter type.- Returns:
- A matcher that matches a getter method with the given type.
-
isGetter
public static <T extends MethodDescription> ElementMatcher.Junction<T> isGetter(TypeDescription type) Matches any Java bean getter method which returns the given type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The required getter type.- Returns:
- A matcher that matches a getter method with the given type.
-
isGenericGetter
public static <T extends MethodDescription> ElementMatcher.Junction<T> isGenericGetter(TypeDescription.Generic type) Matches any Java bean getter method which returns the given type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The required getter type.- Returns:
- A matcher that matches a getter method with the given type.
-
isGetter
public static <T extends MethodDescription> ElementMatcher.Junction<T> isGetter(ElementMatcher<? super TypeDescription> matcher) Matches any Java bean getter method which returns a value with a type matches the supplied matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- A matcher to be allied to a getter method's argument type.- Returns:
- A matcher that matches a getter method with a return type that matches the supplied matcher.
-
isGenericGetter
public static <T extends MethodDescription> ElementMatcher.Junction<T> isGenericGetter(ElementMatcher<? super TypeDescription.Generic> matcher) Matches any Java bean getter method which returns a value with a type matches the supplied matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- A matcher to be allied to a getter method's argument type.- Returns:
- A matcher that matches a getter method with a return type that matches the supplied matcher.
-
hasMethodName
public static <T extends MethodDescription> ElementMatcher.Junction<T> hasMethodName(String internalName) Matches a method against its internal name such that constructors and type initializers are matched appropriately.- Type Parameters:
T
- The type of the matched object.- Parameters:
internalName
- The internal name of the method.- Returns:
- A matcher for a method with the provided internal name.
-
hasSignature
public static <T extends MethodDescription> ElementMatcher.Junction<T> hasSignature(MethodDescription.SignatureToken token) Only matches method descriptions that yield the provided signature token.- Type Parameters:
T
- The type of the matched object.- Parameters:
token
- The signature token to match against.- Returns:
- A matcher for a method with the provided signature token.
-
isSubTypeOf
Matches any type description that is a subtype of the given type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type to be checked for being a subtype of the matched type.- Returns:
- A matcher that matches any type description that represents a sub type of the given type.
-
isSubTypeOf
public static <T extends TypeDescription> ElementMatcher.Junction<T> isSubTypeOf(TypeDescription type) Matches any type description that is a subtype of the given type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type to be checked for being a subtype of the matched type.- Returns:
- A matcher that matches any type description that represents a sub type of the given type.
-
isSuperTypeOf
Matches any type description that is a super type of the given type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type to be checked for being a subtype of the matched type.- Returns:
- A matcher that matches any type description that represents a super type of the given type.
-
isSuperTypeOf
public static <T extends TypeDescription> ElementMatcher.Junction<T> isSuperTypeOf(TypeDescription type) Matches any type description that is a super type of the given type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The type to be checked for being a subtype of the matched type.- Returns:
- A matcher that matches any type description that represents a super type of the given type.
-
hasSuperClass
public static <T extends TypeDescription> ElementMatcher.Junction<T> hasSuperClass(ElementMatcher<? super TypeDescription> matcher) Matches any type description that declares a super class (but not interface) that matches the provided matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The type to be checked for being a super class of the matched type.- Returns:
- A matcher that matches any type description that declares a super class that matches the provided matcher.
-
hasGenericSuperClass
public static <T extends TypeDescription> ElementMatcher.Junction<T> hasGenericSuperClass(ElementMatcher<? super TypeDescription.Generic> matcher) Matches any type description that declares a super class (but not interface) that matches the provided matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The type to be checked for being a super class of the matched type.- Returns:
- A matcher that matches any type description that declares a super class that matches the provided matcher.
-
hasSuperType
public static <T extends TypeDescription> ElementMatcher.Junction<T> hasSuperType(ElementMatcher<? super TypeDescription> matcher) Matches any type description that declares a super type that matches the provided matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The type to be checked for being a super type of the matched type.- Returns:
- A matcher that matches any type description that declares a super type that matches the provided matcher.
-
hasGenericSuperType
public static <T extends TypeDescription> ElementMatcher.Junction<T> hasGenericSuperType(ElementMatcher<? super TypeDescription.Generic> matcher) Matches any type description that declares a super type that matches the provided matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The type to be checked for being a super type of the matched type.- Returns:
- A matcher that matches any type description that declares a super type that matches the provided matcher.
-
inheritsAnnotation
public static <T extends TypeDescription> ElementMatcher.Junction<T> inheritsAnnotation(Class<?> type) Matches any annotations by their type on a type that declared these annotations or inherited them from its super classes.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The annotation type to be matched.- Returns:
- A matcher that matches any inherited annotation by their type.
-
inheritsAnnotation
public static <T extends TypeDescription> ElementMatcher.Junction<T> inheritsAnnotation(TypeDescription type) Matches any annotations by their type on a type that declared these annotations or inherited them from its super classes.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The annotation type to be matched.- Returns:
- A matcher that matches any inherited annotation by their type.
-
inheritsAnnotation
public static <T extends TypeDescription> ElementMatcher.Junction<T> inheritsAnnotation(ElementMatcher<? super TypeDescription> matcher) Matches any annotations by a given matcher on a type that declared these annotations or inherited them from its super classes.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- A matcher to apply onto the inherited annotations.- Returns:
- A matcher that matches any inherited annotation by a given matcher.
-
hasAnnotation
public static <T extends TypeDescription> ElementMatcher.Junction<T> hasAnnotation(ElementMatcher<? super AnnotationDescription> matcher) Matches a list of annotations by a given matcher on a type that declared these annotations or inherited them from its super classes.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- A matcher to apply onto a list of inherited annotations.- Returns:
- A matcher that matches a list of inherited annotation by a given matcher.
-
declaresField
public static <T extends TypeDefinition> ElementMatcher.Junction<T> declaresField(ElementMatcher<? super FieldDescription> matcher) Matches a type by another matcher that is applied on any of its declared fields.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher that is applied onto each declared field.- Returns:
- A matcher that matches any type where another matcher is matched positively on at least on declared field.
-
declaresMethod
public static <T extends TypeDefinition> ElementMatcher.Junction<T> declaresMethod(ElementMatcher<? super MethodDescription> matcher) Matches a type by another matcher that is applied on any of its declared methods.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher that is applied onto each declared method.- Returns:
- A matcher that matches any type where another matcher is matched positively on at least on declared methods.
-
ofSort
public static <T extends TypeDefinition> ElementMatcher.Junction<T> ofSort(TypeDefinition.Sort sort) Matches generic type descriptions of the given sort.- Type Parameters:
T
- The type of the matched object.- Parameters:
sort
- The generic type sort to match.- Returns:
- A matcher that matches generic types of the given sort.
-
ofSort
public static <T extends TypeDefinition> ElementMatcher.Junction<T> ofSort(ElementMatcher<? super TypeDefinition.Sort> matcher) Matches generic type descriptions of the given sort.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- A matcher for a generic type's sort.- Returns:
- A matcher that matches generic types of the given sort.
-
isPrimitive
Matches a type if it is primitive.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that determines if a type is primitive.
-
isArray
Matches a type if it is an array type.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that determines if a type is an array type.
-
isRecord
Matches a type if it is a record type.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that determines if a type is a record type.
-
genericFieldType
public static <T extends FieldDescription> ElementMatcher.Junction<T> genericFieldType(Type fieldType) Matches a field's generic type against the provided matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
fieldType
- The field type to match.- Returns:
- A matcher matching the provided field type.
-
genericFieldType
public static <T extends FieldDescription> ElementMatcher.Junction<T> genericFieldType(TypeDescription.Generic fieldType) Matches a field's generic type against the provided matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
fieldType
- The field type to match.- Returns:
- A matcher matching the provided field type.
-
genericFieldType
public static <T extends FieldDescription> ElementMatcher.Junction<T> genericFieldType(ElementMatcher<? super TypeDescription.Generic> matcher) Matches a field's generic type against the provided matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher to apply to the field's type.- Returns:
- A matcher matching the provided field type.
-
fieldType
Matches a field's raw type against the provided matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
fieldType
- The field type to match.- Returns:
- A matcher matching the provided field type.
-
fieldType
public static <T extends FieldDescription> ElementMatcher.Junction<T> fieldType(TypeDescription fieldType) Matches a field's raw type against the provided matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
fieldType
- The field type to match.- Returns:
- A matcher matching the provided field type.
-
fieldType
public static <T extends FieldDescription> ElementMatcher.Junction<T> fieldType(ElementMatcher<? super TypeDescription> matcher) Matches a field's raw type against the provided matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher to apply to the field's type.- Returns:
- A matcher matching the provided field type.
-
isVolatile
Matches avolatile
field.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a
volatile
field.
-
isTransient
Matches atransient
field.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher for a
transient
field.
-
annotationType
public static <T extends AnnotationDescription> ElementMatcher.Junction<T> annotationType(Class<? extends Annotation> type) Matches if an annotation is of a given type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The expected annotation type.- Returns:
- A matcher that matches the annotation's type for being equal to the given type.
-
annotationType
public static <T extends AnnotationDescription> ElementMatcher.Junction<T> annotationType(TypeDescription type) Matches if an annotation is of a given type.- Type Parameters:
T
- The type of the matched object.- Parameters:
type
- The expected annotation type.- Returns:
- A matcher that matches the annotation's type for being equal to the given type.
-
annotationType
public static <T extends AnnotationDescription> ElementMatcher.Junction<T> annotationType(ElementMatcher<? super TypeDescription> matcher) Matches if an annotation's type matches the supplied matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher to match the annotation's type against.- Returns:
- A matcher that matches the annotation's type.
-
targetsElement
public static <T extends AnnotationDescription> ElementMatcher.Junction<T> targetsElement(ElementType elementType) Matches if an annotation can target a given element type.- Type Parameters:
T
- The type of the matched object.- Parameters:
elementType
- The element type we target.- Returns:
- A matcher that matches annotations that target an element type.
-
isBootstrapClassLoader
Matches exactly the bootstrapClassLoader
. The returned matcher is a synonym to a matcher matchingnull
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that only matches the bootstrap class loader.
-
isSystemClassLoader
Matches exactly the systemClassLoader
. The returned matcher is a synonym to a matcher matchingClassLoader.gerSystemClassLoader()
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that only matches the system class loader.
-
isExtensionClassLoader
Matches exactly the extensionClassLoader
. The returned matcher is a synonym to a matcher matchingClassLoader.gerSystemClassLoader().getParent()
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that only matches the extension class loader.
-
isChildOf
public static <T extends ClassLoader> ElementMatcher.Junction<T> isChildOf(@MaybeNull ClassLoader classLoader) Matches any class loader that is either the given class loader or a child of the given class loader.- Type Parameters:
T
- The type of the matched object.- Parameters:
classLoader
- The class loader of which child class loaders are matched.- Returns:
- A matcher that matches the given class loader and any class loader that is a child of the given class loader.
-
hasChild
public static <T extends ClassLoader> ElementMatcher.Junction<T> hasChild(ElementMatcher<? super ClassLoader> matcher) Matches all class loaders in the hierarchy of the matched class loader against a given matcher.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher to apply to all class loaders in the hierarchy of the matched class loader.- Returns:
- A matcher that matches all class loaders in the hierarchy of the matched class loader.
-
isParentOf
public static <T extends ClassLoader> ElementMatcher.Junction<T> isParentOf(@MaybeNull ClassLoader classLoader) Matches any class loader that is either the given class loader or a parent of the given class loader.- Type Parameters:
T
- The type of the matched object.- Parameters:
classLoader
- The class loader of which parent class loaders are matched.- Returns:
- A matcher that matches the given class loader and any class loader that is a parent of the given class loader.
-
ofType
public static <T extends ClassLoader> ElementMatcher.Junction<T> ofType(ElementMatcher<? super TypeDescription> matcher) Matches a class loader's type unless it is the bootstrap class loader which is never matched.- Type Parameters:
T
- The type of the matched object.- Parameters:
matcher
- The matcher to apply to the class loader's type.- Returns:
- A matcher that matches the class loader's type.
-
supportsModules
Matches a module if it exists, i.e. notnull
.- Type Parameters:
T
- The type of the matched object.- Returns:
- A matcher that validates a module's existence.
-