T
- the type of Component
supported by this matcher.public abstract class NamedComponentMatcherTemplate<T extends Component> extends GenericTypeMatcher<T>
Component
by name. Subclasses are free to add other properties to use as
search criteria.Modifier | Constructor and Description |
---|---|
protected |
NamedComponentMatcherTemplate(Class<T> supportedType)
Creates a new
NamedComponentMatcherTemplate . |
protected |
NamedComponentMatcherTemplate(Class<T> supportedType,
Object name)
Creates a new
NamedComponentMatcherTemplate . |
Modifier and Type | Method and Description |
---|---|
protected static Object |
anyValue() |
protected boolean |
arePropertyValuesMatching(Object expected,
Object actual)
Indicates whether the given value matches the expected value in this matcher.
|
protected boolean |
isNameMatching(String actual)
Indicates whether the given value matches the name in this matcher.
|
protected Object |
name() |
protected Object |
quoted(Object propertyValue)
Returns the given property value to match surrounded by double quotes.
|
protected Object |
quotedName()
Returns the name to match surrounded by double quotes.
|
isMatching, matches, supportedType
requireShowing, requireShowing, requireShowingMatches, reset
protected NamedComponentMatcherTemplate(@Nonnull Class<T> supportedType)
NamedComponentMatcherTemplate
.supportedType
- the type supported by this matcher.NullPointerException
- if the given type is null
.protected NamedComponentMatcherTemplate(@Nonnull Class<T> supportedType, @Nullable Object name)
NamedComponentMatcherTemplate
.supportedType
- the type supported by this matcher.name
- the name to match.NullPointerException
- if the given type is null
.@Nullable protected final Object quotedName()
anyValue()
. This method is commonly used in implementations of toString
.anyValue()
if the name to match has
not been set.@Nullable protected final Object quoted(@Nullable Object propertyValue)
anyValue()
. This method is commonly used in implementations of toString
.propertyValue
- the given property value.anyValue()
if the property value
has not been set.protected final boolean isNameMatching(@Nullable String actual)
true
if this
matcher's name is anyValue()
.actual
- the actual name of an AWT or Swing Component
.true
if this matcher's name is ANY
or if both the actual name is equal to the one in this
matcher. Otherwise false
.protected final boolean arePropertyValuesMatching(@Nullable Object expected, @Nullable Object actual)
true
if the expected value is anyValue()
String
s, it checks for equality first. If this fails, it
tries to match the values assuming the expected value can be a regular expressionPattern
and the actual value is a CharSequence
, regular expression
matching is performedexpected
- the expected value in this matcher.actual
- the actual property value.true
if the values match, otherwise false
.Copyright © 2014–2019 AssertJ. All rights reserved.