public final class JTextComponentMatcher extends NamedComponentMatcherTemplate<JTextComponent>
JTextComponent
s by name, text or visibility on the screen.Modifier and Type | Method and Description |
---|---|
JTextComponentMatcher |
andShowing()
Indicates that the
JTextComponent to match should be showing on the screen. |
JTextComponentMatcher |
andText(Pattern textPattern)
Specifies the text to match.
|
JTextComponentMatcher |
andText(String newText)
Specifies the text to match.
|
static JTextComponentMatcher |
any()
Creates a new
JTextComponentMatcher that matches any JTextComponent . |
protected boolean |
isMatching(JTextComponent textComponent)
Indicates whether the text of the given
JTextComponent is equal to the text in this matcher. |
String |
toString() |
static JTextComponentMatcher |
withName(String name)
Creates a new
JTextComponentMatcher that matches a JTextComponent by name. |
static JTextComponentMatcher |
withText(Pattern textPattern)
Creates a new
JTextComponentMatcher that matches a JTextComponent by its text. |
static JTextComponentMatcher |
withText(String text)
Creates a new
JTextComponentMatcher that matches a JTextComponent by text. |
anyValue, arePropertyValuesMatching, isNameMatching, name, quoted, quotedName
matches, supportedType
requireShowing, requireShowing, requireShowingMatches, reset
@Nonnull public static JTextComponentMatcher withName(@Nullable String name)
Creates a new JTextComponentMatcher
that matches a JTextComponent
by name.
The following code listing shows how to match a JTextComponent
by name and text:
JTextComponentMatcher m =withName
("lastName").andText
("Wang");
The following code listing shows how to match a JTextComponent
, that should be showing on the screen, by
name and text:
JTextComponentMatcher m =withName
("lastName").andText
("Wang").andShowing
();
name
- the id to match.@Nonnull public static JTextComponentMatcher withText(@Nonnull String text)
Creates a new JTextComponentMatcher
that matches a JTextComponent
by text.
The following code listing shows how to match a JTextComponent
by text:
JTextComponentMatcher m = withText
("Wang");
The following code listing shows how to match a JTextComponent
, that should be showing on the screen, by
text:
JTextComponentMatcher m =withText
("Wang").andShowing
();
text
- the text to match. It can be a regular expression.@Nonnull public static JTextComponentMatcher withText(@Nonnull Pattern textPattern)
Creates a new JTextComponentMatcher
that matches a JTextComponent
by its text.
The following code listing shows how to match a JTextComponent
by text, using a regular expression pattern:
JTextComponentMatcher m = withText
(Pattern.compile("W.*"));
The following code listing shows how to match a JTextComponent
, that should be showing on the screen, by
text, using a regular expression pattern:
JTextComponentMatcher m =withText
(Pattern.compile("W.*")).andShowing
();
textPattern
- the text to match. It can be a regular expression.@Nonnull public static JTextComponentMatcher any()
JTextComponentMatcher
that matches any JTextComponent
.@Nonnull public JTextComponentMatcher andText(@Nonnull String newText)
withText(String)
or
withText(Pattern)
, this method will simply update the text to match.newText
- the new text to match. It can be a regular expression.@Nonnull public JTextComponentMatcher andText(@Nonnull Pattern textPattern)
withText(String)
or
withText(Pattern)
, this method will simply update the text to match.textPattern
- the regular expression pattern to match.@Nonnull public JTextComponentMatcher andShowing()
JTextComponent
to match should be showing on the screen.@RunsInCurrentThread protected boolean isMatching(@Nonnull JTextComponent textComponent)
Indicates whether the text of the given JTextComponent
is equal to the text in this matcher.
Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT). Client code must call this method from the EDT.
isMatching
in class GenericTypeMatcher<JTextComponent>
textComponent
- the JTextComponent
to match.true
if the text in the JTextComponent
is equal to the text in this matcher, false
otherwise.Copyright © 2014–2019 AssertJ. All rights reserved.