Module org.testfx

Class NodeQueryImpl

    • Constructor Summary

      Constructors 
      Constructor Description
      NodeQueryImpl()  
    • Method Summary

      Modifier and Type Method Description
      NodeQuery from​(Collection<javafx.scene.Node> parentNodes)
      Stores all given parentNodes within this NodeQuery.
      NodeQuery from​(javafx.scene.Node... parentNodes)
      Stores all given parentNodes within this NodeQuery.
      NodeQuery lookup​(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 those Nodes that meet the query.
      NodeQuery lookup​(Function<javafx.scene.Node,​Set<javafx.scene.Node>> function)
      Sifts through stored nodes and uses function to determine which nodes to keep and which to remove.
      <T extends javafx.scene.Node>
      NodeQuery
      lookup​(Predicate<T> predicate)
      Sifts through stored nodes and keeps only those Nodes that pass the given predicate.
      <T> NodeQuery lookup​(org.hamcrest.Matcher<T> matcher)
      Sifts through stored nodes and keeps only those Nodes that match the given matcher.
      <T extends javafx.scene.Node>
      NodeQuery
      match​(Predicate<T> predicate)
      Sifts through stored nodes and keeps only those Nodes that pass the given predicate.
      <T> NodeQuery match​(org.hamcrest.Matcher<T> matcher)
      Sifts through stored nodes and keeps only those Nodes that match the given matcher.
      NodeQuery nth​(int index)
      Keeps the nth Node in stored nodes and removes all others.
      <T extends javafx.scene.Node>
      T
      query()
      Executes this NodeQuery and returns the first Node found that matches this query.
      <T extends javafx.scene.Node>
      Set<T>
      queryAll()
      Executes this NodeQuery and returns the Set of all the Nodes that match this query.
      <T extends javafx.scene.Node>
      Set<T>
      queryAllAs​(Class<T> clazz)
      Type-safe version of NodeQuery.queryAll() that executes this NodeQuery and returns the Set of all the Nodes that match this query.
      <T extends javafx.scene.Node>
      T
      queryAs​(Class<T> clazz)
      Type-safe version of NodeQuery.query() that executes this NodeQuery and returns the first Node found that matches this query.
      String toString()  
      <T extends javafx.scene.Node>
      Optional<T>
      tryQuery()
      Executes this NodeQuery and returns an Optional that either contains the first Node found that matches this query or nothing (e.g.
      <T extends javafx.scene.Node>
      Optional<T>
      tryQueryAs​(Class<T> clazz)
      Type-safe version of NodeQuery.tryQuery() that executes this NodeQuery and returns an Optional that either contains the first Node found that matches this query or nothing (e.g.
    • Constructor Detail

      • NodeQueryImpl

        public NodeQueryImpl()
    • Method Detail

      • from

        public NodeQuery from​(javafx.scene.Node... parentNodes)
        Description copied from interface: NodeQuery
        Stores all given parentNodes within this NodeQuery.
        Specified by:
        from in interface NodeQuery
        Parameters:
        parentNodes - the parentNodes to store
        Returns:
        itself for more method chaining
      • from

        public NodeQuery from​(Collection<javafx.scene.Node> parentNodes)
        Description copied from interface: NodeQuery
        Stores all given parentNodes within this NodeQuery.
        Specified by:
        from in interface NodeQuery
        Parameters:
        parentNodes - the parentNodes to store
        Returns:
        itself for more method chaining
      • lookup

        public NodeQuery lookup​(String query)
        Description copied from interface: NodeQuery
        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 those Nodes that meet the query.
        Specified by:
        lookup in interface NodeQuery
        Parameters:
        query - the query to use
        Returns:
        itself for more method chaining
      • lookup

        public <T> NodeQuery lookup​(org.hamcrest.Matcher<T> matcher)
        Description copied from interface: NodeQuery
        Sifts through stored nodes and keeps only those Nodes that match the given matcher.
        Specified by:
        lookup in interface NodeQuery
        Type Parameters:
        T - matcher type
        Parameters:
        matcher - the matcher used to determine which Nodes to keep and which to remove
        Returns:
        itself for more method chaining
      • lookup

        public <T extends javafx.scene.Node> NodeQuery lookup​(Predicate<T> predicate)
        Description copied from interface: NodeQuery
        Sifts through stored nodes and keeps only those Nodes that pass the given predicate.
        Specified by:
        lookup in interface NodeQuery
        Type Parameters:
        T - type that extends Node
        Parameters:
        predicate - the predicate used to determine which Nodes to keep and which to remove.
        Returns:
        itself for more method chaining
      • lookup

        public NodeQuery lookup​(Function<javafx.scene.Node,​Set<javafx.scene.Node>> function)
        Description copied from interface: NodeQuery
        Sifts through stored nodes and uses function to determine which nodes to keep and which to remove.
        Specified by:
        lookup in interface NodeQuery
        Parameters:
        function - that returns the Nodes to keep
        Returns:
        itself for more method chaining
      • match

        public <T> NodeQuery match​(org.hamcrest.Matcher<T> matcher)
        Description copied from interface: NodeQuery
        Sifts through stored nodes and keeps only those Nodes that match the given matcher.
        Specified by:
        match in interface NodeQuery
        Type Parameters:
        T - matcher type
        Parameters:
        matcher - that determines which Nodes to keep
        Returns:
        itself for more method chaining
      • match

        public <T extends javafx.scene.Node> NodeQuery match​(Predicate<T> predicate)
        Description copied from interface: NodeQuery
        Sifts through stored nodes and keeps only those Nodes that pass the given predicate.
        Specified by:
        match in interface NodeQuery
        Type Parameters:
        T - predicate type
        Parameters:
        predicate - that indicates which Nodes to keep
        Returns:
        itself for more method chaining
      • nth

        public NodeQuery nth​(int index)
        Description copied from interface: NodeQuery
        Keeps the nth Node in stored nodes and removes all others.
        Specified by:
        nth in interface NodeQuery
        Parameters:
        index - within the collection of Nodes
        Returns:
        itself for more method chaining
      • query

        public <T extends javafx.scene.Node> T query()
        Description copied from interface: NodeQuery
        Executes this NodeQuery and returns the first Node found that matches this query. If no nodes match this query then an EmptyNodeQueryException is 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:
        query in interface NodeQuery
        Type Parameters:
        T - the type that extends Node
        Returns:
        the first node found that matches this query, if any
      • queryAs

        public <T extends javafx.scene.Node> T queryAs​(Class<T> clazz)
        Description copied from interface: NodeQuery
        Type-safe version of NodeQuery.query() that executes this NodeQuery and returns the first Node found that matches this query. If no nodes match this query then an EmptyNodeQueryException is 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:
        queryAs in interface NodeQuery
        Type Parameters:
        T - the type that extends Node
        Parameters:
        clazz - the concrete sub-type of Node that 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> Optional<T> tryQuery()
        Description copied from interface: NodeQuery
        Executes this NodeQuery and returns an Optional that either contains the first Node found 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:
        tryQuery in interface NodeQuery
        Type Parameters:
        T - the type that extends Node
        Returns:
        the first node found or an empty Optional if the query does not match any nodes
      • tryQueryAs

        public <T extends javafx.scene.Node> Optional<T> tryQueryAs​(Class<T> clazz)
        Description copied from interface: NodeQuery
        Type-safe version of NodeQuery.tryQuery() that executes this NodeQuery and returns an Optional that either contains the first Node found 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:
        tryQueryAs in interface NodeQuery
        Type Parameters:
        T - the type that extends Node
        Parameters:
        clazz - the concrete sub-type of Node that should be contained in the Optional returned by this query so as to avoid extraneous casting when used inside an "assertThat" assertion
        Returns:
        the first node found or an empty Optional if the query does not match any nodes
      • queryAll

        public <T extends javafx.scene.Node> Set<T> queryAll()
        Description copied from interface: NodeQuery
        Executes this NodeQuery and returns the Set of all the Nodes that match this query. If no nodes match this query, the empty set is returned.
        Specified by:
        queryAll in interface NodeQuery
        Type Parameters:
        T - the type that extends Node
        Returns:
        the set of nodes that match this query
      • queryAllAs

        public <T extends javafx.scene.Node> Set<T> queryAllAs​(Class<T> clazz)
        Description copied from interface: NodeQuery
        Type-safe version of NodeQuery.queryAll() that executes this NodeQuery and returns the Set of all the Nodes that match this query. If no nodes match this query, the empty set is returned.
        Specified by:
        queryAllAs in interface NodeQuery
        Type Parameters:
        T - the type that extends Node
        Parameters:
        clazz - the concrete sub-type of Node the 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