Package cdc.util.data.util
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 Summary
Fields Modifier and Type Field Description static AttributePredicateANY_ATTRIBUTEAn attribute predicate that always returnstrue.static AttributePredicateIS_EMPTY_ATTRIBUTEAn attribute predicate that returnstruewhen an attribute value isnullor empty.static AttributePredicateIS_NOT_EMPTY_ATTRIBUTEAn attribute predicate that returnstruewhen an attribute value is neithernullnor empty.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleanaccepts(Element element, String name, String value)Returnstruewhen the attribute must be kept.default AttributePredicateand(AttributePredicate other)Returns a predicate that is the logicalandcombination of this one and another one.static AttributePredicatefromNames(Collection<String> names)Returns an AttributePredicate that returns true when the attribute has a names belonging to a collection.static AttributePredicatefromPaths(Collection<SPath> paths)default AttributePredicatenot()default AttributePredicateor(AttributePredicate other)Returns a predicate that is the logicalorcombination of this one and another one.
-
-
-
Field Detail
-
ANY_ATTRIBUTE
static final AttributePredicate ANY_ATTRIBUTE
An attribute predicate that always returnstrue.
-
IS_EMPTY_ATTRIBUTE
static final AttributePredicate IS_EMPTY_ATTRIBUTE
An attribute predicate that returnstruewhen an attribute value isnullor empty.
-
IS_NOT_EMPTY_ATTRIBUTE
static final AttributePredicate IS_NOT_EMPTY_ATTRIBUTE
An attribute predicate that returnstruewhen an attribute value is neithernullnor empty.
-
-
Method Detail
-
accepts
boolean accepts(Element element, String name, String value)
Returnstruewhen 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.
-
not
default AttributePredicate not()
- Returns:
- The negation of this predicate.
-
and
default AttributePredicate and(AttributePredicate 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 AttributePredicate or(AttributePredicate 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 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- Whennamesisnull.
-
fromPaths
static AttributePredicate fromPaths(Collection<SPath> paths)
-
-