Class NodeQueryImpl
- java.lang.Object
-
- org.testfx.service.query.impl.NodeQueryImpl
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringCSS_CLASS_SELECTOR_PREFIXprivate static java.lang.StringCSS_ID_SELECTOR_PREFIXprivate java.util.Set<javafx.scene.Node>parentNodesprivate java.util.List<java.lang.String>queryDescriptors
-
Constructor Summary
Constructors Constructor Description NodeQueryImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description NodeQueryfrom(java.util.Collection<javafx.scene.Node> parentNodes)Stores all givenparentNodeswithin this NodeQuery.NodeQueryfrom(javafx.scene.Node... parentNodes)Stores all givenparentNodeswithin this NodeQuery.private static booleanisCssSelector(java.lang.String query)NodeQuerylookup(java.lang.String query)Sifts through stored nodes by their id ("#id"), their class (".class"), or the text it has ("text"), depending on the query used, and keeps only thoseNodes that meet the query.NodeQuerylookup(java.util.function.Function<javafx.scene.Node,java.util.Set<javafx.scene.Node>> function)Sifts through stored nodes and usesfunctionto determine which nodes to keep and which to remove.<T extends javafx.scene.Node>
NodeQuerylookup(java.util.function.Predicate<T> predicate)Sifts through stored nodes and keeps only thoseNodes that pass the givenpredicate.<T> NodeQuerylookup(org.hamcrest.Matcher<T> matcher)Sifts through stored nodes and keeps only thoseNodes that match the given matcher.<T extends javafx.scene.Node>
NodeQuerymatch(java.util.function.Predicate<T> predicate)Sifts through stored nodes and keeps only thoseNodes that pass the given predicate.<T> NodeQuerymatch(org.hamcrest.Matcher<T> matcher)Sifts through stored nodes and keeps only thoseNodes that match the given matcher.NodeQuerynth(int index)Keeps the nthNodein stored nodes and removes all others.private static java.lang.Stringordinal(int i)https://stackoverflow.com/a/6810409/3634630<T extends javafx.scene.Node>
Tquery()Executes thisNodeQueryand returns the firstNodefound that matches this query.<T extends javafx.scene.Node>
java.util.Set<T>queryAll()Executes thisNodeQueryand returns theSetof all theNodes that match this query.<T extends javafx.scene.Node>
java.util.Set<T>queryAllAs(java.lang.Class<T> clazz)Type-safe version ofNodeQuery.queryAll()that executes thisNodeQueryand returns theSetof all theNodes that match this query.<T extends javafx.scene.Node>
TqueryAs(java.lang.Class<T> clazz)Type-safe version ofNodeQuery.query()that executes thisNodeQueryand returns the firstNodefound that matches this query.java.lang.StringtoString()<T extends javafx.scene.Node>
java.util.Optional<T>tryQuery()Executes thisNodeQueryand returns anOptionalthat either contains the firstNodefound that matches this query or nothing (e.g.<T extends javafx.scene.Node>
java.util.Optional<T>tryQueryAs(java.lang.Class<T> clazz)Type-safe version ofNodeQuery.tryQuery()that executes thisNodeQueryand returns anOptionalthat either contains the firstNodefound that matches this query or nothing (e.g.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.testfx.service.query.NodeQuery
queryButton, queryComboBox, queryLabeled, queryListView, queryParent, queryTableView, queryText, queryTextFlow, queryTextInputControl
-
-
-
-
Field Detail
-
CSS_ID_SELECTOR_PREFIX
private static final java.lang.String CSS_ID_SELECTOR_PREFIX
- See Also:
- Constant Field Values
-
CSS_CLASS_SELECTOR_PREFIX
private static final java.lang.String CSS_CLASS_SELECTOR_PREFIX
- See Also:
- Constant Field Values
-
parentNodes
private java.util.Set<javafx.scene.Node> parentNodes
-
queryDescriptors
private final java.util.List<java.lang.String> queryDescriptors
-
-
Method Detail
-
from
public NodeQuery from(javafx.scene.Node... parentNodes)
Description copied from interface:NodeQueryStores all givenparentNodeswithin this NodeQuery.
-
from
public NodeQuery from(java.util.Collection<javafx.scene.Node> parentNodes)
Description copied from interface:NodeQueryStores all givenparentNodeswithin this NodeQuery.
-
lookup
public NodeQuery lookup(java.lang.String query)
Description copied from interface:NodeQuerySifts through stored nodes by their id ("#id"), their class (".class"), or the text it has ("text"), depending on the query used, and keeps only thoseNodes that meet the query.
-
lookup
public <T> NodeQuery lookup(org.hamcrest.Matcher<T> matcher)
Description copied from interface:NodeQuerySifts through stored nodes and keeps only thoseNodes that match the given matcher.
-
lookup
public <T extends javafx.scene.Node> NodeQuery lookup(java.util.function.Predicate<T> predicate)
Description copied from interface:NodeQuerySifts through stored nodes and keeps only thoseNodes that pass the givenpredicate.
-
lookup
public NodeQuery lookup(java.util.function.Function<javafx.scene.Node,java.util.Set<javafx.scene.Node>> function)
Description copied from interface:NodeQuerySifts through stored nodes and usesfunctionto determine which nodes to keep and which to remove.
-
match
public <T> NodeQuery match(org.hamcrest.Matcher<T> matcher)
Description copied from interface:NodeQuerySifts through stored nodes and keeps only thoseNodes that match the given matcher.
-
match
public <T extends javafx.scene.Node> NodeQuery match(java.util.function.Predicate<T> predicate)
Description copied from interface:NodeQuerySifts through stored nodes and keeps only thoseNodes that pass the given predicate.
-
nth
public NodeQuery nth(int index)
Description copied from interface:NodeQueryKeeps the nthNodein stored nodes and removes all others.
-
query
public <T extends javafx.scene.Node> T query()
Description copied from interface:NodeQueryExecutes thisNodeQueryand returns the firstNodefound that matches this query. If no nodes match this query then anEmptyNodeQueryExceptionis thrown.The determinism of this method relies on the determinism of
Node.lookupAll(String), for which the JavaDocs specifically state that the result is unordered. The current (9.0.4) version of JavaFX happens to return the nodes in the order in which they are encountered whilst traversing the scene graph but this could change in future versions of JavaFX. Thus if there are multiple nodes matched by this query and you want a specific one it is advised not to use this method and instead narrow the query so that only one node is matched.
-
queryAs
public <T extends javafx.scene.Node> T queryAs(java.lang.Class<T> clazz)
Description copied from interface:NodeQueryType-safe version ofNodeQuery.query()that executes thisNodeQueryand returns the firstNodefound that matches this query. If no nodes match this query then anEmptyNodeQueryExceptionis thrown.The determinism of this method relies on the determinism of
Node.lookupAll(String), for which the JavaDocs specifically state that the result is unordered. The current (9.0.4) version of JavaFX happens to return the nodes in the order in which they are encountered whilst traversing the scene graph but this could change in future versions of JavaFX. Thus if there are multiple nodes matched by this query and you want a specific one it is advised not to use this method and instead narrow the query so that only one node is matched.- Specified by:
queryAsin interfaceNodeQuery- Type Parameters:
T- the type that extendsNode- Parameters:
clazz- the concrete sub-type ofNodethat should be returned by this query so as to avoid extraneous casting when used inside an "assertThat" assertion- Returns:
- the first node found that matches this query, if any
-
tryQuery
public <T extends javafx.scene.Node> java.util.Optional<T> tryQuery()
Description copied from interface:NodeQueryExecutes thisNodeQueryand returns anOptionalthat either contains the firstNodefound that matches this query or nothing (e.g.Optional.empty()returns true) if no nodes match this query.The determinism of this method relies on the determinism of
Node.lookupAll(String), for which the JavaDocs specifically state that the result is unordered. The current (9.0.4) version of JavaFX happens to return the nodes in the order in which they are encountered whilst traversing the scene graph but this could change in future versions of JavaFX. Thus if there are multiple nodes matched by this query and you want a specific one it is advised not to use this method and instead narrow the query so that only one node is matched.
-
tryQueryAs
public <T extends javafx.scene.Node> java.util.Optional<T> tryQueryAs(java.lang.Class<T> clazz)
Description copied from interface:NodeQueryType-safe version ofNodeQuery.tryQuery()that executes thisNodeQueryand returns anOptionalthat either contains the firstNodefound that matches this query or nothing (e.g.Optional.empty()returns true) if no nodes match this query.The determinism of this method relies on the determinism of
Node.lookupAll(String), for which the JavaDocs specifically state that the result is unordered. The current (9.0.4) version of JavaFX happens to return the nodes in the order in which they are encountered whilst traversing the scene graph but this could change in future versions of JavaFX. Thus if there are multiple nodes matched by this query and you want a specific one it is advised not to use this method and instead narrow the query so that only one node is matched.- Specified by:
tryQueryAsin interfaceNodeQuery- Type Parameters:
T- the type that extendsNode- Parameters:
clazz- the concrete sub-type ofNodethat should be contained in theOptionalreturned by this query so as to avoid extraneous casting when used inside an "assertThat" assertion- Returns:
- the first node found or an empty
Optionalif the query does not match any nodes
-
queryAll
public <T extends javafx.scene.Node> java.util.Set<T> queryAll()
Description copied from interface:NodeQueryExecutes thisNodeQueryand returns theSetof all theNodes that match this query. If no nodes match this query, the empty set is returned.
-
queryAllAs
public <T extends javafx.scene.Node> java.util.Set<T> queryAllAs(java.lang.Class<T> clazz)
Description copied from interface:NodeQueryType-safe version ofNodeQuery.queryAll()that executes thisNodeQueryand returns theSetof all theNodes that match this query. If no nodes match this query, the empty set is returned.- Specified by:
queryAllAsin interfaceNodeQuery- Type Parameters:
T- the type that extendsNode- Parameters:
clazz- the concrete sub-type ofNodethe set of which should be returned by this query so as to avoid extraneous casting when used inside an "assertThat" assertion- Returns:
- the set of nodes that match this query
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isCssSelector
private static boolean isCssSelector(java.lang.String query)
-
ordinal
private static java.lang.String ordinal(int i)
https://stackoverflow.com/a/6810409/3634630
-
-