Package spoon.legacy

Class NameFilter<T extends CtNamedElement>

java.lang.Object
spoon.legacy.NameFilter<T>
All Implemented Interfaces:
Filter<T>

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)
      Parameters:
      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>
      Parameters:
      element - - the element to be checked for a match. Parameter element is never null if Query is used.
    • getType

      public Class<T> getType()