Class CollectionsExpressionVariable
java.lang.Object
com.broadleafcommerce.rulesengine.expression.util.CollectionsExpressionVariable
- All Implemented Interfaces:
ExpressionVariable
Common, null-safe, collection operations
An instance of this class will usually be accessible as a variable within an expression via
#collections
. This is partly a wrapper around CollectionUtils
to provide a layer
of abstraction and because CollectionUtils employs static methods. Note that not all methods of
CollectionUtils
have been implemented just those that seemed most relevant for expression
evaluation.
- Author:
- Nathan Moore (nathandmoore)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> boolean
contains
(T value, Collection<T> collection) boolean
containsAll
(Collection<?> coll2, Collection<?> coll1) Whether the second collection contains all of the elements from the first.boolean
containsAny
(Collection<?> coll2, Collection<?> coll1) Whether the second collection contains any elements from the first.boolean
containsNone
(Collection<?> coll2, Collection<?> coll1) Whether the second collections contains none of the elements form the first.boolean
equals
(Collection<?> coll2, Collection<?> coll1) Performs a deep equals on the 2 collections.getName()
boolean
isEmpty
(Collection<?> collection) Whether the collection is empty or null.<T> boolean
notContains
(Collection<T> value, Collection<T> collection) Whether the collection defined byvalue
is not contained by the collection.<T> boolean
notContains
(T[] value, Collection<T> collection) Whether the array defined byvalue
is not contained by the collection.<T> boolean
notContains
(T value, Collection<T> collection) Whether the value is not contained by the collection.
-
Field Details
-
NAME
- See Also:
-
-
Constructor Details
-
CollectionsExpressionVariable
public CollectionsExpressionVariable()
-
-
Method Details
-
getName
- Specified by:
getName
in interfaceExpressionVariable
- Returns:
- Name of the variable, must not be null
-
isEmpty
Whether the collection is empty or null. -
equals
Performs a deep equals on the 2 collections. -
contains
Whether thevalue
is found within thecollection
usingCollection.contains(Object)
. This method is dynamic and will work slightly differently when given an array or a collection to validate against. In that scenario, the contents ofvalue
are traversed to see if all of the elements are contained withincollection
. Ifvalue
is null, then thecollection
must contain a null value- Parameters:
value
- what to check for, which can also be an array or collectioncollection
- collection to check- Returns:
- whether or not everything defined by
value
is contained withincollection
-
notContains
Whether the value is not contained by the collection. -
notContains
Whether the collection defined byvalue
is not contained by the collection. -
notContains
Whether the array defined byvalue
is not contained by the collection. -
containsAny
Whether the second collection contains any elements from the first. If either is null, returns false. -
containsAll
Whether the second collection contains all of the elements from the first. If both are empty or null, returns true -
containsNone
Whether the second collections contains none of the elements form the first. If either is null, returns true.
-