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 ofComponent
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 Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
NamedComponentMatcherTemplate
(Class<T> supportedType) Creates a newNamedComponentMatcherTemplate
.protected
NamedComponentMatcherTemplate
(Class<T> supportedType, Object name) Creates a newNamedComponentMatcherTemplate
. -
Method Summary
Modifier and TypeMethodDescriptionprotected final boolean
arePropertyValuesMatching
(Object expected, Object actual) Indicates whether the given value matches the expected value in this matcher.protected final boolean
isNameMatching
(String actual) Indicates whether the given value matches the name in this matcher.protected final Object
Returns the given property value to match surrounded by double quotes.protected final Object
Returns the component name to match surrounded by double quotes.Methods inherited from class org.fest.swing.core.GenericTypeMatcher
isMatching, matches, supportedType
Methods 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 ofANY
toString
.- 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 ofANY
toString
.- 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 returnstrue
if this matcher's name is
.ANY
- Parameters:
actual
- the actual component name.- Returns:
true
if this matcher's name isANY
or 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
true
if the expected value isANY
- if both the expected and actual values are
String
s, 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:
true
if the values match, otherwisefalse
.
- it always returns
-