Class ElementMatchers


  • public final class ElementMatchers
    extends java.lang.Object
    A utility class that contains a human-readable language for creating ElementMatchers.
    • Field Detail

      • BOOTSTRAP_CLASSLOADER

        private static final java.lang.ClassLoader BOOTSTRAP_CLASSLOADER
        A readable reference to the bootstrap class loader which is represented by null.
    • Constructor Detail

      • ElementMatchers

        private ElementMatchers()
        A private constructor that must not be invoked.
    • Method Detail

      • failSafe

        public 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 an Exception.
        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,
                                                            java.util.concurrent.ConcurrentMap<? super T,​java.lang.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. Using cached(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

        public static <T> ElementMatcher.Junction<T> is​(java.lang.Object value)
        Matches the given value which can also be null by the Object.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

        public static <T extends FieldDescriptionElementMatcher.Junction<T> is​(java.lang.reflect.Field field)
        Exactly matches a given field as a FieldDescription 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 MethodDescriptionElementMatcher.Junction<T> is​(java.lang.reflect.Method method)
        Exactly matches a given method as a MethodDescription 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 MethodDescriptionElementMatcher.Junction<T> is​(java.lang.reflect.Constructor<?> constructor)
        Exactly matches a given constructor as a MethodDescription 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.
      • hasType

        public static <T extends ParameterDescriptionElementMatcher.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 ParameterDescriptionElementMatcher.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

        public static <T extends ParameterDescriptionElementMatcher.Junction<T> isMandated()
        Matches a parameter description for a mandated parameter.
        Type Parameters:
        T - The type of the matched object.
        Returns:
        A matcher for a mandated parameter.
      • is

        public static <T extends TypeDefinitionElementMatcher.Junction<T> is​(java.lang.reflect.Type type)
        Exactly matches a given type as a TypeDescription.
        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 AnnotationDescriptionElementMatcher.Junction<T> is​(java.lang.annotation.Annotation annotation)
        Exactly matches a given annotation as an AnnotationDescription.
        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

        public static <T> ElementMatcher.Junction<T> not​(ElementMatcher<? super T> matcher)
        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

        public static <T> ElementMatcher.Junction<T> any()
        Creates a matcher that always returns true.
        Type Parameters:
        T - The type of the matched object.
        Returns:
        A matcher that matches anything.
      • none

        public static <T> ElementMatcher.Junction<T> none()
        Creates a matcher that always returns false.
        Type Parameters:
        T - The type of the matched object.
        Returns:
        A matcher that matches nothing.
      • anyOf

        public static <T> ElementMatcher.Junction<T> anyOf​(java.lang.Object... value)

        Creates a matcher that matches any of the given objects by the Object.equals(Object) method. None of the values must be null.

        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

        public static <T> ElementMatcher.Junction<T> anyOf​(java.lang.Iterable<?> values)

        Creates a matcher that matches any of the given objects by the Object.equals(Object) method. None of the values must be null.

        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

        public static <T extends TypeDefinitionElementMatcher.Junction<T> anyOf​(java.lang.reflect.Type... value)
        Creates a matcher that matches any of the given types as TypeDescriptions by the Object.equals(Object) method. None of the values must be null.
        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 MethodDescriptionElementMatcher.Junction<T> anyOf​(java.lang.reflect.Constructor<?>... value)
        Creates a matcher that matches any of the given constructors as MethodDescriptions by the Object.equals(Object) method. None of the values must be null.
        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 MethodDescriptionElementMatcher.Junction<T> anyOf​(java.lang.reflect.Method... value)
        Creates a matcher that matches any of the given methods as MethodDescriptions by the Object.equals(Object) method. None of the values must be null.
        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 FieldDescriptionElementMatcher.Junction<T> anyOf​(java.lang.reflect.Field... value)
        Creates a matcher that matches any of the given fields as FieldDescriptions by the Object.equals(Object) method. None of the values must be null.
        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 AnnotationDescriptionElementMatcher.Junction<T> anyOf​(java.lang.annotation.Annotation... value)
        Creates a matcher that matches any of the given annotations as AnnotationDescriptions by the Object.equals(Object) method. None of the values must be null.
        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

        public static <T> ElementMatcher.Junction<T> noneOf​(java.lang.Object... value)
        Creates a matcher that matches none of the given objects by the Object.equals(Object) method. None of the values must be null.
        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> ElementMatcher.Junction<T> noneOf​(java.lang.Iterable<?> values)
        Creates a matcher that matches none of the given objects by the Object.equals(Object) method. None of the values must be null.
        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

        public static <T extends TypeDefinitionElementMatcher.Junction<T> noneOf​(java.lang.reflect.Type... value)
        Creates a matcher that matches none of the given types as TypeDescriptions by the Object.equals(Object) method. None of the values must be null.
        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 MethodDescriptionElementMatcher.Junction<T> noneOf​(java.lang.reflect.Constructor<?>... value)
        Creates a matcher that matches none of the given constructors as MethodDescriptions by the Object.equals(Object) method. None of the values must be null.
        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 MethodDescriptionElementMatcher.Junction<T> noneOf​(java.lang.reflect.Method... value)
        Creates a matcher that matches none of the given methods as MethodDescriptions by the Object.equals(Object) method. None of the values must be null.
        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 FieldDescriptionElementMatcher.Junction<T> noneOf​(java.lang.reflect.Field... value)
        Creates a matcher that matches none of the given methods as FieldDescriptions by the Object.equals(Object) method. None of the values must be null.
        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 AnnotationDescriptionElementMatcher.Junction<T> noneOf​(java.lang.annotation.Annotation... value)
        Creates a matcher that matches none of the given annotations as AnnotationDescriptions by the Object.equals(Object) method. None of the values must be null.
        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<java.lang.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<java.lang.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

        public static <T extends TypeDescription.GenericElementMatcher.Junction<T> erasure​(java.lang.Class<?> 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.GenericElementMatcher.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.GenericElementMatcher.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 java.lang.Iterable<? extends TypeDescription.Generic>> ElementMatcher.Junction<T> erasures​(java.lang.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 java.lang.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 java.lang.Iterable<? extends TypeDescription.Generic>> ElementMatcher.Junction<T> erasures​(java.lang.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 java.lang.Iterable<? extends TypeDescription.Generic>> ElementMatcher.Junction<T> erasures​(ElementMatcher<? super java.lang.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

        public static <T extends TypeDefinitionElementMatcher.Junction<T> isVariable​(java.lang.String symbol)
        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 TypeDefinitionElementMatcher.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

        public static <T extends NamedElementElementMatcher.Junction<T> named​(java.lang.String name)
        Matches a NamedElement 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

        public static <T extends NamedElementElementMatcher.Junction<T> namedOneOf​(java.lang.String... names)
        Matches a NamedElement 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

        public static <T extends NamedElementElementMatcher.Junction<T> namedIgnoreCase​(java.lang.String name)
        Matches a NamedElement 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

        public static <T extends NamedElementElementMatcher.Junction<T> nameStartsWith​(java.lang.String prefix)
        Matches a NamedElement 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 NamedElementElementMatcher.Junction<T> nameStartsWithIgnoreCase​(java.lang.String prefix)
        Matches a NamedElement 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

        public static <T extends NamedElementElementMatcher.Junction<T> nameEndsWith​(java.lang.String suffix)
        Matches a NamedElement 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 NamedElementElementMatcher.Junction<T> nameEndsWithIgnoreCase​(java.lang.String suffix)
        Matches a NamedElement 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

        public static <T extends NamedElementElementMatcher.Junction<T> nameContains​(java.lang.String infix)
        Matches a NamedElement 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 NamedElementElementMatcher.Junction<T> nameContainsIgnoreCase​(java.lang.String infix)
        Matches a NamedElement 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

        public static <T extends NamedElementElementMatcher.Junction<T> nameMatches​(java.lang.String regex)
        Matches a NamedElement 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.
      • isDeclaredBy

        public static <T extends ByteCodeElementElementMatcher.Junction<T> isDeclaredBy​(java.lang.Class<?> type)
        Matches a ByteCodeElement for being declared by a given Class. 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 ByteCodeElementElementMatcher.Junction<T> isDeclaredBy​(TypeDescription type)
        Matches a ByteCodeElement for being declared by a given TypeDescription. 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 ByteCodeElementElementMatcher.Junction<T> isDeclaredBy​(ElementMatcher<? super TypeDescription> matcher)
        Matches a ByteCodeElement for being declared by a TypeDescription 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 not null.
        Returns:
        A matcher for byte code elements being declared by a type matched by the given matcher.
      • isDeclaredByGeneric

        public static <T extends ByteCodeElementElementMatcher.Junction<T> isDeclaredByGeneric​(java.lang.reflect.Type type)
        Matches a ByteCodeElement for being declared by a given generic 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.
      • isVisibleTo

        public static <T extends ByteCodeElementElementMatcher.Junction<T> isVisibleTo​(java.lang.Class<?> type)
        Matches a ByteCodeElement that is visible to a given Class.
        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

        public static <T extends ByteCodeElementElementMatcher.Junction<T> isAccessibleTo​(java.lang.Class<?> type)
        Matches a ByteCodeElement that is accessible to a given Class.
        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 ByteCodeElementElementMatcher.Junction<T> isAccessibleTo​(TypeDescription type)
        Matches a ByteCodeElement that is accessible to a given Class.
        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.
      • isAnnotatedWith

        public static <T extends AnnotationSourceElementMatcher.Junction<T> isAnnotatedWith​(java.lang.Class<? extends java.lang.annotation.Annotation> type)
        Matches an AnnotationSource for declared annotations. This matcher does not match inherited annotations which only exist for classes. Use inheritsAnnotation(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 AnnotationSourceElementMatcher.Junction<T> isAnnotatedWith​(TypeDescription type)
        Matches an AnnotationSource for declared annotations. This matcher does not match inherited annotations which only exist for classes. Use inheritsAnnotation(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.
      • returnsGeneric

        public static <T extends MethodDescriptionElementMatcher.Junction<T> returnsGeneric​(java.lang.reflect.Type type)
        Matches MethodDescriptions 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.
      • returns

        public static <T extends MethodDescriptionElementMatcher.Junction<T> returns​(java.lang.Class<?> type)
        Matches MethodDescriptions 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 MethodDescriptionElementMatcher.Junction<T> returns​(TypeDescription type)
        Matches MethodDescriptions 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 MethodDescriptionElementMatcher.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.
      • takesGenericArgument

        public static <T extends MethodDescriptionElementMatcher.Junction<T> takesGenericArgument​(int index,
                                                                                                    java.lang.reflect.Type type)
        Matches MethodDescriptions 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 MethodDescriptionElementMatcher.Junction<T> takesGenericArgument​(int index,
                                                                                                    TypeDescription.Generic type)
        Matches MethodDescriptions 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 MethodDescriptionElementMatcher.Junction<T> takesGenericArgument​(int index,
                                                                                                    ElementMatcher<? super TypeDescription.Generic> matcher)
        Matches MethodDescriptions 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 MethodDescriptionElementMatcher.Junction<T> takesGenericArguments​(java.lang.reflect.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 MethodDescriptionElementMatcher.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 MethodDescriptionElementMatcher.Junction<T> takesGenericArguments​(java.util.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 MethodDescriptionElementMatcher.Junction<T> takesGenericArguments​(ElementMatcher<? super java.lang.Iterable<? extends TypeDescription.Generic>> matchers)
        Matches a MethodDescription by applying an iterable collection of element matcher on any parameter's TypeDescription.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 MethodDescriptionElementMatcher.Junction<T> takesArgument​(int index,
                                                                                             java.lang.Class<?> type)
        Matches MethodDescriptions 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 MethodDescriptionElementMatcher.Junction<T> takesArgument​(int index,
                                                                                             TypeDescription type)
        Matches MethodDescriptions 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 MethodDescriptionElementMatcher.Junction<T> takesArgument​(int index,
                                                                                             ElementMatcher<? super TypeDescription> matcher)
        Matches MethodDescriptions 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 MethodDescriptionElementMatcher.Junction<T> takesArguments​(java.lang.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 MethodDescriptionElementMatcher.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 MethodDescriptionElementMatcher.Junction<T> takesArguments​(java.lang.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 MethodDescriptionElementMatcher.Junction<T> takesArguments​(ElementMatcher<? super java.lang.Iterable<? extends TypeDescription>> matchers)
        Matches a MethodDescription by applying an iterable collection of element matcher on any parameter's TypeDescription.
        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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> takesArguments​(int length)
        Matches a MethodDescription 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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> takesNoArguments()
        Matches a MethodDescription 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 MethodDescriptionElementMatcher.Junction<T> hasParameters​(ElementMatcher<? super java.lang.Iterable<? extends ParameterDescription>> matcher)
        Matches a MethodDescription 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 MethodDescriptionElementMatcher.Junction<T> canThrow​(java.lang.Class<? extends java.lang.Throwable> exceptionType)
        Matches a MethodDescription 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 MethodDescriptionElementMatcher.Junction<T> canThrow​(TypeDescription exceptionType)
        Matches a MethodDescription 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 MethodDescriptionElementMatcher.Junction<T> declaresGenericException​(java.lang.reflect.Type exceptionType)
        Matches a method that declares the given generic exception type. For non-generic type, this matcher behaves identically to declaresException(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 MethodDescriptionElementMatcher.Junction<T> declaresGenericException​(TypeDescription.Generic exceptionType)
        Matches a method that declares the given generic exception type. For non-generic type, this matcher behaves identically to declaresException(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 MethodDescriptionElementMatcher.Junction<T> declaresException​(java.lang.Class<? extends java.lang.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 MethodDescriptionElementMatcher.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 MethodDescriptionElementMatcher.Junction<T> declaresGenericException​(ElementMatcher<? super java.lang.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 MethodDescriptionElementMatcher.Junction<T> isOverriddenFrom​(java.lang.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 MethodDescriptionElementMatcher.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 MethodDescriptionElementMatcher.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 MethodDescriptionElementMatcher.Junction<T> isOverriddenFromGeneric​(java.lang.reflect.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 MethodDescriptionElementMatcher.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 MethodDescriptionElementMatcher.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.
      • isMethod

        public static <T extends MethodDescriptionElementMatcher.Junction<T> isMethod()
        Only matches method descriptions that represent a Method.
        Type Parameters:
        T - The type of the matched object.
        Returns:
        A matcher that only matches method descriptions that represent a Java method.
      • isConstructor

        public static <T extends MethodDescriptionElementMatcher.Junction<T> isConstructor()
        Only matches method descriptions that represent a Constructor.
        Type Parameters:
        T - The type of the matched object.
        Returns:
        A matcher that only matches method descriptions that represent a Java constructor.
      • isTypeInitializer

        public static <T extends MethodDescriptionElementMatcher.Junction<T> isTypeInitializer()
        Only matches method descriptions that represent a Class 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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> 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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> 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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> 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.
      • isDefaultFinalizer

        public static <T extends MethodDescriptionElementMatcher.Junction<T> isDefaultFinalizer()
        Only matches the Object.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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> isFinalizer()
        Only matches the Object.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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> isHashCode()
        Only matches the Object.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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> isEquals()
        Only matches the Object.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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> isClone()
        Only matches the Object.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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> isToString()
        Only matches the Object.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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> 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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> isSetter​(java.lang.String property)
        An element matcher that matches any setter for the given property. When given an empty string, any setter named set 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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> isSetter​(java.lang.Class<?> 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 any setter method.
      • isGenericSetter

        public static <T extends MethodDescriptionElementMatcher.Junction<T> isGenericSetter​(java.lang.reflect.Type 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 any setter method.
      • isSetter

        public static <T extends MethodDescriptionElementMatcher.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 MethodDescriptionElementMatcher.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 MethodDescriptionElementMatcher.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 MethodDescriptionElementMatcher.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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> 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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> isGetter​(java.lang.String property)
        An element matcher that matches any getter for the given property. When given an empty string, any getter named get is matched despite that such a getter is not fulfilling the Java bean naming conventions. If a getter's type is boolean or Boolean, 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

        public static <T extends MethodDescriptionElementMatcher.Junction<T> isGetter​(java.lang.Class<?> 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 MethodDescriptionElementMatcher.Junction<T> isGenericGetter​(java.lang.reflect.Type 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 MethodDescriptionElementMatcher.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 MethodDescriptionElementMatcher.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 MethodDescriptionElementMatcher.Junction<T> isGetter​(ElementMatcher<? super TypeDescription> matcher)
        Matches any Java bean getter method which returns an 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 MethodDescriptionElementMatcher.Junction<T> isGenericGetter​(ElementMatcher<? super TypeDescription.Generic> matcher)
        Matches any Java bean getter method which returns an 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 MethodDescriptionElementMatcher.Junction<T> hasMethodName​(java.lang.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 MethodDescriptionElementMatcher.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

        public static <T extends TypeDescriptionElementMatcher.Junction<T> isSubTypeOf​(java.lang.Class<?> 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.
      • isSubTypeOf

        public static <T extends TypeDescriptionElementMatcher.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

        public static <T extends TypeDescriptionElementMatcher.Junction<T> isSuperTypeOf​(java.lang.Class<?> 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.
      • isSuperTypeOf

        public static <T extends TypeDescriptionElementMatcher.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 TypeDescriptionElementMatcher.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 TypeDescriptionElementMatcher.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 TypeDescriptionElementMatcher.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 TypeDescriptionElementMatcher.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 TypeDescriptionElementMatcher.Junction<T> inheritsAnnotation​(java.lang.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 TypeDescriptionElementMatcher.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 TypeDescriptionElementMatcher.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 TypeDescriptionElementMatcher.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 TypeDefinitionElementMatcher.Junction<T> declaresField​(ElementMatcher<? super FieldDescription> matcher)
        Matches a type by a 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 TypeDefinitionElementMatcher.Junction<T> declaresMethod​(ElementMatcher<? super MethodDescription> matcher)
        Matches a type by a 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 TypeDefinitionElementMatcher.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 TypeDefinitionElementMatcher.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

        public static <T extends TypeDefinitionElementMatcher.Junction<T> 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

        public static <T extends TypeDefinitionElementMatcher.Junction<T> 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

        public static <T extends TypeDefinitionElementMatcher.Junction<T> 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 FieldDescriptionElementMatcher.Junction<T> genericFieldType​(java.lang.reflect.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 FieldDescriptionElementMatcher.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 FieldDescriptionElementMatcher.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

        public static <T extends FieldDescriptionElementMatcher.Junction<T> fieldType​(java.lang.Class<?> 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 FieldDescriptionElementMatcher.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 FieldDescriptionElementMatcher.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

        public static <T extends FieldDescriptionElementMatcher.Junction<T> isVolatile()
        Matches a volatile field.
        Type Parameters:
        T - The type of the matched object.
        Returns:
        A matcher for a volatile field.
      • isTransient

        public static <T extends FieldDescriptionElementMatcher.Junction<T> isTransient()
        Matches a transient field.
        Type Parameters:
        T - The type of the matched object.
        Returns:
        A matcher for a transient field.
      • annotationType

        public static <T extends AnnotationDescriptionElementMatcher.Junction<T> annotationType​(java.lang.Class<? extends java.lang.annotation.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 AnnotationDescriptionElementMatcher.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 AnnotationDescriptionElementMatcher.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 AnnotationDescriptionElementMatcher.Junction<T> targetsElement​(java.lang.annotation.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

        public static <T extends java.lang.ClassLoader> ElementMatcher.Junction<T> isBootstrapClassLoader()
        Matches exactly the bootstrap ClassLoader. The returned matcher is a synonym to a matcher matching null.
        Type Parameters:
        T - The type of the matched object.
        Returns:
        A matcher that only matches the bootstrap class loader.
      • isSystemClassLoader

        public static <T extends java.lang.ClassLoader> ElementMatcher.Junction<T> isSystemClassLoader()
        Matches exactly the system ClassLoader. The returned matcher is a synonym to a matcher matching ClassLoader.gerSystemClassLoader().
        Type Parameters:
        T - The type of the matched object.
        Returns:
        A matcher that only matches the system class loader.
      • isExtensionClassLoader

        public static <T extends java.lang.ClassLoader> ElementMatcher.Junction<T> isExtensionClassLoader()
        Matches exactly the extension ClassLoader. The returned matcher is a synonym to a matcher matching ClassLoader.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 java.lang.ClassLoader> ElementMatcher.Junction<T> isChildOf​(java.lang.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 java.lang.ClassLoader> ElementMatcher.Junction<T> hasChild​(ElementMatcher<? super java.lang.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 java.lang.ClassLoader> ElementMatcher.Junction<T> isParentOf​(java.lang.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 java.lang.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

        public static <T extends JavaModuleElementMatcher.Junction<T> supportsModules()
        Matches a module if it exists, i.e. not null.
        Type Parameters:
        T - The type of the matched object.
        Returns:
        A matcher that validates a module's existence.