Interface TextPredicate

  • 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 interface TextPredicate
    Interface used to filter text nodes.
    Author:
    Damien Carbonne
    • Method Detail

      • accepts

        boolean accepts​(Parent parent,
                        Text text)
        Returns true when a text must be kept.

        Text (and its parents) must have been created before this can be called.

        Parameters:
        parent - The text parent.
        text - The text node.
        Returns:
        true if text must be kept, false otherwise.
      • not

        default TextPredicate not()
        Returns:
        The negation of this predicate.
      • and

        default TextPredicate and​(TextPredicate other)
        Returns a predicate that is the logical and combination of this one and another one.
        Parameters:
        other - The other predicate.
        Returns:
        A predicate that is the logical and combination of this one and other.
        Throws:
        IllegalArgumentException - When other is null.
      • or

        default TextPredicate or​(TextPredicate other)
        Returns a predicate that is the logical or combination of this one and another one.
        Parameters:
        other - The other predicate.
        Returns:
        A predicate that is the logical or combination of this one and other.
        Throws:
        IllegalArgumentException - When other is null.
      • fromElementNames

        static TextPredicate fromElementNames​(Collection<String> names)
        Returns an TextPredicate that returns true when the text id defined in an element whose name belongs to a collection.

        It is advised to use an efficient collection, typically a Set.

        Parameters:
        names - The collections of names. MUST NOT be null.
        Returns:
        A new instance of TextPredicate that returns true when the text is in an element whose name belong to names.
        Throws:
        IllegalArgumentException - When names is null.