org.fest.swing.core
Class GenericTypeMatcher<T extends Component>

java.lang.Object
  extended by org.fest.swing.core.AbstractComponentMatcher
      extended by org.fest.swing.core.GenericTypeMatcher<T>
Type Parameters:
T - the type of Component supported by this matcher.
All Implemented Interfaces:
ComponentMatcher, ResettableComponentMatcher
Direct Known Subclasses:
NamedComponentMatcherTemplate

public abstract class GenericTypeMatcher<T extends Component>
extends AbstractComponentMatcher

Understands a ComponentMatcher that matches a Component by type and some custom search criteria.

Author:
Yvonne Wang, Alex Ruiz

Constructor Summary
GenericTypeMatcher(Class<T> supportedType)
          Creates a new GenericTypeMatcher.
GenericTypeMatcher(Class<T> supportedType, boolean requireShowing)
          Creates a new GenericTypeMatcher.
 
Method Summary
protected abstract  boolean isMatching(T component)
          Verifies that the given component matches some search criteria.
 boolean matches(Component c)
          Verifies that the given Component: Is an instance of the generic type specified in this ComponentMatcher Matches some search criteria Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.)
 Class<T> supportedType()
          Returns the supported type of this matcher.
 
Methods inherited from class org.fest.swing.core.AbstractComponentMatcher
requireShowing, requireShowing, requireShowingMatches, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericTypeMatcher

public GenericTypeMatcher(Class<T> supportedType)
Creates a new GenericTypeMatcher. The component to match does not have to be showing.

Parameters:
supportedType - the type supported by this matcher.
Throws:
NullPointerException - if the given type is null.

GenericTypeMatcher

public GenericTypeMatcher(Class<T> supportedType,
                          boolean requireShowing)
Creates a new GenericTypeMatcher.

Parameters:
supportedType - the type supported by this matcher.
requireShowing - indicates if the component to match should be showing or not.
Throws:
NullPointerException - if the given type is null.
Method Detail

matches

@RunsInCurrentThread
public final boolean matches(Component c)
Verifies that the given Component:
  1. Is an instance of the generic type specified in this ComponentMatcher
  2. Matches some search criteria

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.

Parameters:
c - the Component to verify.
Returns:
true if the given Component is an instance of the generic type of this matcher and matches some search criteria. Otherwise, false.

supportedType

public final Class<T> supportedType()
Returns the supported type of this matcher.

Returns:
the supported type of this matcher.

isMatching

@RunsInCurrentThread
protected abstract boolean isMatching(T component)
Verifies that the given component matches some search criteria.

Note: Implementations of this method may not be guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for invoking this method in the EDT.

Parameters:
component - the Component to verify.
Returns:
true if the given component matches the defined search criteria; otherwise, false .


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.