Interface AttributePredicate

  • 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 AttributePredicate
    Interface used to filter attributes.
    Author:
    Damien Carbonne
    • Field Detail

      • ANY_ATTRIBUTE

        static final AttributePredicate ANY_ATTRIBUTE
        An attribute predicate that always returns true.
      • IS_EMPTY_ATTRIBUTE

        static final AttributePredicate IS_EMPTY_ATTRIBUTE
        An attribute predicate that returns true when an attribute value is null or empty.
      • IS_NOT_EMPTY_ATTRIBUTE

        static final AttributePredicate IS_NOT_EMPTY_ATTRIBUTE
        An attribute predicate that returns true when an attribute value is neither null nor empty.
    • Method Detail

      • accepts

        boolean accepts​(Element element,
                        String name,
                        String value)
        Returns true when the attribute must be kept.
        Parameters:
        element - The element containing the attribute.
        name - The attribute name.
        value - The attribute value.
        Returns:
        True if attribute must be kept, false otherwise.
      • and

        default AttributePredicate and​(AttributePredicate 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 AttributePredicate or​(AttributePredicate 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.
      • fromNames

        static AttributePredicate fromNames​(Collection<String> names)
        Returns an AttributePredicate that returns true when the attribute has a names belonging 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 AttributePredicate that returns true when the attribute name belong to names.
        Throws:
        IllegalArgumentException - When names is null.