Class MethodOverrideMatcher<T extends MethodDescription>

Type Parameters:
T - The type of the matched entity.
All Implemented Interfaces:
ElementMatcher<T>, ElementMatcher.Junction<T>

@Enhance public class MethodOverrideMatcher<T extends MethodDescription> extends ElementMatcher.Junction.ForNonNullValues<T>
A matcher that checks if any super type of a type declares a method with the same shape of a matched method.
  • Field Details

  • Constructor Details

    • MethodOverrideMatcher

      public MethodOverrideMatcher(ElementMatcher<? super TypeDescription.Generic> matcher)
      Creates a new method override matcher.
      Parameters:
      matcher - The matcher that is to be applied to the type that declares a method of the same shape.
  • Method Details

    • doMatch

      protected boolean doMatch(T target)
      Matches the supplied value if it was found not to be null.
      Specified by:
      doMatch in class ElementMatcher.Junction.ForNonNullValues<T extends MethodDescription>
      Parameters:
      target - The instance to be matched.
      Returns:
      true if the given element is matched by this matcher or false otherwise.
    • matches

      private boolean matches(MethodDescription target, List<? extends TypeDefinition> typeDefinitions, Set<TypeDescription> duplicates)
      Matches a method against a list of types.
      Parameters:
      target - The method that is matched as a target.
      typeDefinitions - The type definitions to check if they declare a method with the same signature as target.
      duplicates - A set containing duplicate interfaces that do not need to be revisited.
      Returns:
      true if any type defines a method with the same signature as the target method.
    • matches

      private boolean matches(MethodDescription target, TypeDefinition typeDefinition)
      Checks if a type declares a method with the same signature as target.
      Parameters:
      target - The method to be checked.
      typeDefinition - The type to check for declaring a method with the same signature as target.
      Returns:
      true if the supplied type declares a compatible method.
    • toString

      public String toString()
      Overrides:
      toString in class Object