Class NamedComponentMatcherTemplate<T extends Component>

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

public abstract class NamedComponentMatcherTemplate<T extends Component> extends GenericTypeMatcher<T>
Understands a template for matching components by name. Subclasses are free to add other properties to use as search criteria.
  • Field Details

    • ANY

      protected static final Object ANY
      Indicates that a property value to use as search criteria has not been set.
    • name

      protected final Object name
      The component name to match.
  • Constructor Details

  • Method Details

    • quotedName

      protected final Object quotedName()
      Returns the component name to match surrounded by double quotes. If the component name has not been set, it will return ANY. This method is commonly used in implementations of toString.
      Returns:
      the component name to match surrounded by double quotes, or ANY if the component name has not been set.
    • quoted

      protected final Object quoted(Object propertyValue)
      Returns the given property value to match surrounded by double quotes. If the property has not been set, it will return ANY. This method is commonly used in implementations of toString.
      Parameters:
      propertyValue - the given property value.
      Returns:
      the given property value to match surrounded by double quotes, or ANY if the property value has not been set.
    • isNameMatching

      protected final boolean isNameMatching(String actual)
      Indicates whether the given value matches the name in this matcher. It always returns true if this matcher's name is ANY.
      Parameters:
      actual - the actual component name.
      Returns:
      true if this matcher's name is ANY or if both the actual name is equal to the one in this matcher. Otherwise false.
    • arePropertyValuesMatching

      protected final boolean arePropertyValuesMatching(Object expected, Object actual)
      Indicates whether the given value matches the expected value in this matcher. Matching is performed as follows:
      1. it always returns true if the expected value is ANY
      2. if both the expected and actual values are Strings, it checks for equality first. If this fails, it tries to match the values assuming the expected value can be a regular expression
      3. if the expected value is a Pattern and the actual value is a CharSequence, regular expression matching is performed
      4. otherwise, it checks that both the expected and actual values are equal
      Parameters:
      expected - the expected value in this matcher.
      actual - the actual property value.
      Returns:
      true if the values match, otherwise false.