Package spoon.legacy

Class NameFilter<T extends CtNamedElement>

All Implemented Interfaces:

public class NameFilter<T extends CtNamedElement> extends Object implements Filter<T>
Filters elements by name (for instance to find a method). Example:
 CtMethod<?> normalFor = type.getElements(
                new NameFilter<CtMethod<?>>("normalFor")).get(0);
Use NamedElementFilter instead: the actual NameFilter could return wrongly typed results. NamedElementFilter explicit the use of a type.
  • Constructor Details

    • NameFilter

      public NameFilter(String name)
      name - Name of the expected element
  • 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>
      element - - the element to be checked for a match. Parameter element is never null if Query is used.
    • getType

      public Class<T> getType()