Class NamedElementFilter<T extends CtNamedElement>

java.lang.Object
spoon.reflect.visitor.filter.NamedElementFilter<T>
All Implemented Interfaces:
Filter<T>

public class NamedElementFilter<T extends CtNamedElement> extends Object implements Filter<T>
Filters elements by name and by type (for instance to find a method). Example:
 CtMethod<?> normalFor = type.getElements(
                new NamedElementFilter<CtMethod<?>>(CtMethod.class, "normalFor")).get(0);
 
  • Constructor Details

    • NamedElementFilter

      public NamedElementFilter(Class<T> acceptedClass, String name)
      Parameters:
      name - Name of the expected element
      acceptedClass - Expected class of the results
  • Method Details

    • matches

      public boolean matches(T element)
      Description copied from interface: Filter
      Tells if the given element matches.
      Specified by:
      matches in interface Filter<T extends CtNamedElement>
      Parameters:
      element - - the element to be checked for a match. Parameter element is never null if Query is used.
    • getType

      public Class<T> getType()