Package cdc.util.data.util
Interface ElementPredicate
-
- 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 ElementPredicate
Interface used to filter elements.- Author:
- Damien Carbonne
-
-
Field Summary
Fields Modifier and Type Field Description static ElementPredicateANY_ELEMENTAn element predicate that always returnstrue.static ElementPredicateEMPTY_ELEMENTAn element predicate that returnstruewhen the element is empty.static ElementPredicatePURE_ELEMENTAn element predicate that returnstruewhen the element is empty and has no attribute.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleanaccepts(Parent parent, Element element)Returns true when an element must be kept.default ElementPredicateand(ElementPredicate other)Returns a predicate that is the logicalandcombination of this one and another one.static ElementPredicatefromNames(Collection<String> names)Returns a predicate that returnstruewhen the element name belongs to a collection.static ElementPredicatefromPaths(Collection<SPath> paths)static ElementPredicatefromPredicate(Predicate<Element> predicate)default ElementPredicatenot()default ElementPredicateor(ElementPredicate other)Returns a predicate that is the logicalorcombination of this one and another one.
-
-
-
Field Detail
-
ANY_ELEMENT
static final ElementPredicate ANY_ELEMENT
An element predicate that always returnstrue.
-
EMPTY_ELEMENT
static final ElementPredicate EMPTY_ELEMENT
An element predicate that returnstruewhen the element is empty.
-
PURE_ELEMENT
static final ElementPredicate PURE_ELEMENT
An element predicate that returnstruewhen the element is empty and has no attribute.
-
-
Method Detail
-
accepts
boolean accepts(Parent parent, Element element)
Returns true when an element must be kept.Element (and its parents) must have been created before this can be called.
However, its children are not necessarily existing at time of filtering.- Parameters:
parent- The element parent.element- The element.- Returns:
- True if element must be kept, false otherwise.
-
not
default ElementPredicate not()
- Returns:
- The negation of this predicate.
-
and
default ElementPredicate and(ElementPredicate other)
Returns a predicate that is the logicalandcombination of this one and another one.- Parameters:
other- The other predicate.- Returns:
- A predicate that is the logical
andcombination of this one andother. - Throws:
IllegalArgumentException- Whenotherisnull.
-
or
default ElementPredicate or(ElementPredicate other)
Returns a predicate that is the logicalorcombination of this one and another one.- Parameters:
other- The other predicate.- Returns:
- A predicate that is the logical
orcombination of this one andother. - Throws:
IllegalArgumentException- Whenotherisnull.
-
fromNames
static ElementPredicate fromNames(Collection<String> names)
Returns a predicate that returnstruewhen the element name belongs to a collection.It is advised to use an efficient collection, typically a Set.
- Parameters:
names- The collection of accepted names.- Returns:
- A predicate that returns
truewhen the element name belongsnames. - Throws:
IllegalArgumentException- Whennamesisnull.
-
fromPaths
static ElementPredicate fromPaths(Collection<SPath> paths)
-
fromPredicate
static ElementPredicate fromPredicate(Predicate<Element> predicate)
-
-