Interface CollectionConditional<C extends CollectionConditional<C>>
- All Superinterfaces:
Conditional<C>,Copyable<C>
- All Known Implementing Classes:
DefaultCollectionConditional
An extension of
Conditional that is used for matching a set of conditionals against each
member of a collection field. This conditional is useful in scenarios where the states of members
of a collection are relevant to gate certain functionality.
For example, a conditional that is a match when all members of a collection have a "type" of "PRODUCT, or is empty:
Conditionals.whenCollection("choices")
.conditional(PropertyConditional.when("type").equalTo("PRODUCT"))
.allMatch()
.matchIfEmpty()
- Author:
- Nick Crum (ncrum)
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault CallMatch()Mark this conditional as requiring all collection member to match the condition.default CanyMatch()Mark this conditional as requiring any collection members to match the conditions.default CClears the current conditions on this conditional.default Cconditional(Conditional<?>... conditionals) Adds one or more conditions to this conditional.default Cconditionals(List<Conditional<?>> conditionals) Adds one or more conditions to this conditional.default CDefine the property name of the collection the conditional targets.List<Conditional<?>>getField()default StringgetType()The type of conditional.booleandefault CMarks this conditional as treating an empty collection as a match.default CmatchStrategy(String matchStrategy) Define the match strategy.default CMarks this conditional as treating an empty collection as NOT a match.voidsetConditionals(List<Conditional<?>> conditionals) voidvoidsetMatchIfEmpty(boolean matchIfEmpty) voidsetMatchStrategy(String matchStrategy) Methods inherited from interface com.broadleafcommerce.metadata.dsl.core.Conditional
self
-
Field Details
-
TYPE
- See Also:
-
-
Method Details
-
getType
Description copied from interface:ConditionalThe type of conditional. This is used to distinguish different types of conditionals.- Specified by:
getTypein interfaceConditional<C extends CollectionConditional<C>>- Returns:
- the type
-
getField
String getField() -
getMatchStrategy
String getMatchStrategy() -
getConditionals
List<Conditional<?>> getConditionals() -
isMatchIfEmpty
boolean isMatchIfEmpty() -
setField
-
setMatchStrategy
-
setConditionals
-
setMatchIfEmpty
void setMatchIfEmpty(boolean matchIfEmpty) -
field
Define the property name of the collection the conditional targets.- Parameters:
field- the property name- Returns:
- this
-
matchStrategy
Define the match strategy. Typically one ofCollectionConditional.CollectionConditionalMatchStrategy.- Parameters:
matchStrategy- the match strategy- Returns:
- this
-
anyMatch
Mark this conditional as requiring any collection members to match the conditions.- Returns:
- this
-
allMatch
Mark this conditional as requiring all collection member to match the condition.- Returns:
- this
-
conditional
Adds one or more conditions to this conditional.- Parameters:
conditionals- the conditional(s)- Returns:
- this
-
conditionals
Adds one or more conditions to this conditional.- Parameters:
conditionals- the conditional(s)- Returns:
- this
-
clearConditionals
Clears the current conditions on this conditional.- Returns:
- this
-
matchIfEmpty
Marks this conditional as treating an empty collection as a match.- Returns:
- this
-
notMatchIfEmpty
Marks this conditional as treating an empty collection as NOT a match.- Returns:
- this
-