Class ComponentFinderTemplate<T extends Component>

java.lang.Object
org.fest.swing.finder.ComponentFinderTemplate<T>
Type Parameters:
T - the type of component this finder can search.
Direct Known Subclasses:
JFileChooserFinder, JOptionPaneFinder, WindowFinderTemplate

public abstract class ComponentFinderTemplate<T extends Component> extends Object
Understands a template for Component finders.
  • Field Details

  • Constructor Details

    • ComponentFinderTemplate

      protected ComponentFinderTemplate(String componentName, Class<? extends T> componentType)
      Parameters:
      componentName - the name of the Component to find.
      componentType - the type of the Component to find.
    • ComponentFinderTemplate

      protected ComponentFinderTemplate(GenericTypeMatcher<? extends T> matcher)
      Parameters:
      matcher - specifies the search criteria to use when looking up a Component.
    • ComponentFinderTemplate

      protected ComponentFinderTemplate(Class<? extends T> componentType)
      Parameters:
      componentType - the type of the Component to find.
    • ComponentFinderTemplate

      private ComponentFinderTemplate(ComponentMatcher matcher)
  • Method Details

    • withTimeout

      protected ComponentFinderTemplate<T> withTimeout(long newTimeout, TimeUnit unit)
      Sets the timeout for this finder. The Component to find should be found within the given time period.
      Parameters:
      newTimeout - the period of time the search should be performed.
      unit - the time unit for timeout.
      Returns:
      this finder.
      Throws:
      NullPointerException - if the time unit is null.
      IllegalArgumentException - if the timeout is a negative number.
    • withTimeout

      protected ComponentFinderTemplate<T> withTimeout(long newTimeout)
      Sets the timeout for this finder. The Component to find should be found within the given time period.
      Parameters:
      newTimeout - the number of milliseconds before stopping the search.
      Returns:
      this finder.
      Throws:
      IllegalArgumentException - if the timeout is a negative number.
    • using

      public abstract ComponentFixture<T> using(Robot robot)
      Finds a component by name or type using the given robot.
      Parameters:
      robot - contains the underlying finding to delegate the search to.
      Returns:
      a fixture capable of managing the found component.
      Throws:
      WaitTimedOutError - if a component with the given name or of the given type could not be found.
    • findComponentWith

      protected final T findComponentWith(Robot robot)
      Finds the component using either by name or type.
      Parameters:
      robot - contains the underlying finding to delegate the search to.
      Returns:
      the found component.
      Throws:
      WaitTimedOutError - if a component with the given name or of the given type could not be found.
    • cast

      protected abstract T cast(Component c)
      Casts the given Component to the type supported by this finder.
      Parameters:
      c - the given Component.
      Returns:
      the given Component casted to the type supported by this finder.