Class NameMatcher

All Implemented Interfaces:
ComponentMatcher, ResettableComponentMatcher

public final class NameMatcher extends AbstractComponentMatcher
Understands Component matching by name and (optionally) by type.
  • Field Details

  • Constructor Details

    • NameMatcher

      public NameMatcher(String name)
      Creates a new NameMatcher. The component to match does not have to be showing.
      Parameters:
      name - the name of the component we are looking for.
      Throws:
      NullPointerException - if the given name is null.
      IllegalArgumentException - if the given name is empty.
    • NameMatcher

      public NameMatcher(String name, boolean requireShowing)
      Creates a new NameMatcher.
      Parameters:
      name - the name of the component we are looking for.
      requireShowing - indicates if the component to match should be showing or not.
      Throws:
      NullPointerException - if the given name is null.
      IllegalArgumentException - if the given name is empty.
    • NameMatcher

      public NameMatcher(String name, Class<? extends Component> type)
      Creates a new NameMatcher. The component to match does not have to be showing.
      Parameters:
      name - the name of the component we are looking for.
      type - the type of the component we are looking for.
      Throws:
      NullPointerException - if the given name is empty.
      IllegalArgumentException - if the given name is empty.
      NullPointerException - if the given type is null.
    • NameMatcher

      public NameMatcher(String name, Class<? extends Component> type, boolean requireShowing)
      Creates a new NameMatcher.
      Parameters:
      name - the name of the component we are looking for.
      type - the type of the component we are looking for.
      requireShowing - indicates if the component to match should be showing or not.
      Throws:
      NullPointerException - if the given name is empty.
      IllegalArgumentException - if the given name is empty.
      NullPointerException - if the given type is null.
  • Method Details

    • matches

      @RunsInCurrentThread public boolean matches(Component c)
      Indicates whether the name and visibility of the given Component matches the value specified in this matcher.

      Note: This method is not executed in the event dispatch thread (EDT.) Clients are responsible for invoking this method in the EDT.

      Parameters:
      c - the Component to verify.
      Returns:
      true if the name and visibility of the given Component matches the values specified in this matcher, false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object