Interface XPathPatterns.Predicate

Enclosing class:
XPathPatterns
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface XPathPatterns.Predicate
Representation of an XPath predicate.

XPath predicates differ from generic predicates (Predicate) and patterns (Pattern) in that they do not apply to an element in isolation, but always as an element of a node-set; both the position of the element and the total size of the node-set may be observed.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default Motif<? extends Node,Node>
    apply(Motif<? extends Node,Node> base)
    Returns a motif that filters the node-set implied by the given motif with this predicate.
    boolean
    selects(IntSupplier size, int position, Node node)
    Checks whether the element at a given position in a node-set is to be selected.
  • Method Details

    • selects

      boolean selects(IntSupplier size, int position, Node node)
      Checks whether the element at a given position in a node-set is to be selected.

      The result may not only depend on the element itself, but also on its position and the total number of elements. The latter is computed lazily on demand, because it may trigger upstream lazy computation of all remaining elements.

      Parameters:
      size - a lazy computation of the total number of elements in the node-set
      position - the one-based position of the element in the node-set
      node - an element of the node-set
      Returns:
      true if the element is to be selected; false otherwise
    • apply

      default Motif<? extends Node,Node> apply(Motif<? extends Node,Node> base)
      Returns a motif that filters the node-set implied by the given motif with this predicate.

      The resulting motif, for a given context node, collects the bindings of the given motif lazily in a node-set, and matches the hole disjunctively against the elements filtered by this predicate.

      Parameters:
      base - the motif to postprocess by filtering
      Returns:
      a motif that filters the node-set implied by base with this predicate
      Throws:
      NullPointerException - if base is null