Interface NodeQuery
-
- All Known Implementing Classes:
NodeQueryImpl
public interface NodeQuery
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default 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.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.<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 ofqueryAll()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 ofquery()that executes thisNodeQueryand returns the firstNodefound that matches this query.default javafx.scene.control.ButtonqueryButton()Executes thisNodeQueryand returns the firstButtonfound that matches this query.default <T> javafx.scene.control.ComboBox<T>queryComboBox()Executes thisNodeQueryand returns the firstComboBoxfound that matches this query.default javafx.scene.control.LabeledqueryLabeled()Executes thisNodeQueryand returns the firstLabeledfound that matches this query.default <T> javafx.scene.control.ListView<T>queryListView()Executes thisNodeQueryand returns the firstListViewfound that matches this query.default javafx.scene.ParentqueryParent()Executes thisNodeQueryand returns the firstParentfound that matches this query.default <T> javafx.scene.control.TableView<T>queryTableView()Executes thisNodeQueryand returns the firstTableViewfound that matches this query.default javafx.scene.text.TextqueryText()Executes thisNodeQueryand returns the firstTextfound that matches this query.default javafx.scene.text.TextFlowqueryTextFlow()Executes thisNodeQueryand returns the firstTextFlowfound that matches this query.default javafx.scene.control.TextInputControlqueryTextInputControl()Executes thisNodeQueryand returns the firstTextInputControlfound that matches this query.<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 oftryQuery()that executes thisNodeQueryand returns anOptionalthat either contains the firstNodefound that matches this query or nothing (e.g.
-
-
-
Method Detail
-
from
NodeQuery from(javafx.scene.Node... parentNodes)
Stores all givenparentNodeswithin this NodeQuery.- Parameters:
parentNodes- the parentNodes to store- Returns:
- itself for more method chaining
-
from
NodeQuery from(java.util.Collection<javafx.scene.Node> parentNodes)
Stores all givenparentNodeswithin this NodeQuery.- Parameters:
parentNodes- the parentNodes to store- Returns:
- itself for more method chaining
-
lookup
NodeQuery lookup(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.- Parameters:
query- the query to use- Returns:
- itself for more method chaining
-
lookup
<T> NodeQuery lookup(org.hamcrest.Matcher<T> matcher)
Sifts through stored nodes and keeps only thoseNodes that match the given matcher.- Type Parameters:
T- matcher type- Parameters:
matcher- the matcher used to determine whichNodes to keep and which to remove- Returns:
- itself for more method chaining
-
lookup
<T extends javafx.scene.Node> NodeQuery lookup(java.util.function.Predicate<T> predicate)
Sifts through stored nodes and keeps only thoseNodes that pass the givenpredicate.- Type Parameters:
T- type that extendsNode- Parameters:
predicate- the predicate used to determine whichNodes to keep and which to remove.- Returns:
- itself for more method chaining
-
lookup
NodeQuery lookup(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.- Parameters:
function- that returns theNodes to keep- Returns:
- itself for more method chaining
-
match
<T> NodeQuery match(org.hamcrest.Matcher<T> matcher)
Sifts through stored nodes and keeps only thoseNodes that match the given matcher.- Type Parameters:
T- matcher type- Parameters:
matcher- that determines whichNodes to keep- Returns:
- itself for more method chaining
-
match
<T extends javafx.scene.Node> NodeQuery match(java.util.function.Predicate<T> predicate)
Sifts through stored nodes and keeps only thoseNodes that pass the given predicate.- Type Parameters:
T- predicate type- Parameters:
predicate- that indicates whichNodes to keep- Returns:
- itself for more method chaining
-
nth
NodeQuery nth(int index)
Keeps the nthNodein stored nodes and removes all others.- Parameters:
index- within the collection ofNodes- Returns:
- itself for more method chaining
-
query
<T extends javafx.scene.Node> T query()
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.- Type Parameters:
T- the type that extendsNode- Returns:
- the first node found that matches this query, if any
- Throws:
EmptyNodeQueryException- if noTextFlownodes match this query
-
queryButton
default javafx.scene.control.Button queryButton()
Executes thisNodeQueryand returns the firstButtonfound 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.- Returns:
- the first
Buttonfound that matches this query, if any - Throws:
EmptyNodeQueryException- if noButtonnodes match this query
-
queryComboBox
default <T> javafx.scene.control.ComboBox<T> queryComboBox()
Executes thisNodeQueryand returns the firstComboBoxfound 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.- Returns:
- the first
ComboBoxfound that matches this query, if any - Throws:
EmptyNodeQueryException- if noComboBoxnodes match this query
-
queryLabeled
default javafx.scene.control.Labeled queryLabeled()
Executes thisNodeQueryand returns the firstLabeledfound 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.- Returns:
- the first
Labeledfound that matches this query, if any - Throws:
EmptyNodeQueryException- if noLabelednodes match this query
-
queryListView
default <T> javafx.scene.control.ListView<T> queryListView()
Executes thisNodeQueryand returns the firstListViewfound 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.- Returns:
- the first
ListViewfound that matches this query, if any - Throws:
EmptyNodeQueryException- if noListViewnodes match this query
-
queryParent
default javafx.scene.Parent queryParent()
Executes thisNodeQueryand returns the firstParentfound 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.- Returns:
- the first
Parentfound that matches this query, if any - Throws:
EmptyNodeQueryException- if noParentnodes match this query
-
queryTableView
default <T> javafx.scene.control.TableView<T> queryTableView()
Executes thisNodeQueryand returns the firstTableViewfound 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.- Returns:
- the first
TableViewfound that matches this query, if any - Throws:
EmptyNodeQueryException- if noTableViewnodes match this query
-
queryText
default javafx.scene.text.Text queryText()
Executes thisNodeQueryand returns the firstTextfound 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.- Returns:
- the first
Textfound that matches this query, if any - Throws:
EmptyNodeQueryException- if noTextnodes match this query
-
queryTextFlow
default javafx.scene.text.TextFlow queryTextFlow()
Executes thisNodeQueryand returns the firstTextFlowfound 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.- Returns:
- the first
TextFlowfound that matches this query, if any - Throws:
EmptyNodeQueryException- if noTextFlownodes match this query
-
queryTextInputControl
default javafx.scene.control.TextInputControl queryTextInputControl()
Executes thisNodeQueryand returns the firstTextInputControlfound 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.- Returns:
- the first
TextInputControlfound that matches this query, if any - Throws:
EmptyNodeQueryException- if noTextInputControlnodes match this query
-
queryAs
<T extends javafx.scene.Node> T queryAs(java.lang.Class<T> clazz)
Type-safe version ofquery()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.- 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
- Throws:
EmptyNodeQueryException- if no nodes match this query
-
tryQuery
<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.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.- Type Parameters:
T- the type that extendsNode- Returns:
- the first node found or an empty
Optionalif the query does not match any nodes
-
tryQueryAs
<T extends javafx.scene.Node> java.util.Optional<T> tryQueryAs(java.lang.Class<T> clazz)
Type-safe version oftryQuery()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.- 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
<T extends javafx.scene.Node> java.util.Set<T> queryAll()
Executes thisNodeQueryand returns theSetof all theNodes that match this query. If no nodes match this query, the empty set is returned.- Type Parameters:
T- the type that extendsNode- Returns:
- the set of nodes that match this query
-
queryAllAs
<T extends javafx.scene.Node> java.util.Set<T> queryAllAs(java.lang.Class<T> clazz)
Type-safe version ofqueryAll()that executes thisNodeQueryand returns theSetof all theNodes that match this query. If no nodes match this query, the empty set is returned.- 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
-
-