Package org.fest.swing.core.matcher
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 ofComponentsupported 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 Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNamedComponentMatcherTemplate(Class<T> supportedType) Creates a newNamedComponentMatcherTemplate.protectedNamedComponentMatcherTemplate(Class<T> supportedType, Object name) Creates a newNamedComponentMatcherTemplate. -
Method Summary
Modifier and TypeMethodDescriptionprotected final booleanarePropertyValuesMatching(Object expected, Object actual) Indicates whether the given value matches the expected value in this matcher.protected final booleanisNameMatching(String actual) Indicates whether the given value matches the name in this matcher.protected final ObjectReturns the given property value to match surrounded by double quotes.protected final ObjectReturns the component name to match surrounded by double quotes.Methods inherited from class org.fest.swing.core.GenericTypeMatcher
isMatching, matches, supportedTypeMethods inherited from class org.fest.swing.core.AbstractComponentMatcher
requireShowing, requireShowing, requireShowingMatches, reset
-
Field Details
-
ANY
Indicates that a property value to use as search criteria has not been set. -
name
The component name to match.
-
-
Constructor Details
-
NamedComponentMatcherTemplate
Creates a newNamedComponentMatcherTemplate.- Parameters:
supportedType- the type supported by this matcher.- Throws:
NullPointerException- if the given type isnull.
-
NamedComponentMatcherTemplate
Creates a newNamedComponentMatcherTemplate.- Parameters:
supportedType- the type supported by this matcher.name- the component name to match.- Throws:
NullPointerException- if the given type isnull.
-
-
Method Details
-
quotedName
Returns the component name to match surrounded by double quotes. If the component name has not been set, it will return. This method is commonly used in implementations ofANYtoString.- Returns:
- the component name to match surrounded by double quotes, or
if the component name has not been set.ANY
-
quoted
Returns the given property value to match surrounded by double quotes. If the property has not been set, it will return. This method is commonly used in implementations ofANYtoString.- Parameters:
propertyValue- the given property value.- Returns:
- the given property value to match surrounded by double quotes, or
if the property value has not been set.ANY
-
isNameMatching
Indicates whether the given value matches the name in this matcher. It always returnstrueif this matcher's name is.ANY- Parameters:
actual- the actual component name.- Returns:
trueif this matcher's name isANYor if both the actual name is equal to the one in this matcher. Otherwisefalse.
-
arePropertyValuesMatching
Indicates whether the given value matches the expected value in this matcher. Matching is performed as follows:- it always returns
trueif the expected value isANY - 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 - if the expected value is a
and the actual value is aPattern, regular expression matching is performedCharSequence - 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:
trueif the values match, otherwisefalse.
- it always returns
-