public interface CollectionConditional<C extends CollectionConditional<C>> extends Conditional<C>
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()
Modifier and Type | Interface and Description |
---|---|
static class |
CollectionConditional.CollectionConditionalMatchStrategy |
Modifier and Type | Method and Description |
---|---|
default C |
allMatch()
Mark this conditional as requiring all collection member to match the condition.
|
default C |
anyMatch()
Mark this conditional as requiring any collection members to match the conditions.
|
default C |
clearConditionals()
Clears the current conditions on this conditional.
|
default C |
conditional(Conditional<?>... conditionals)
Adds one or more conditions to this conditional.
|
default C |
conditionals(List<Conditional<?>> conditionals)
Adds one or more conditions to this conditional.
|
default C |
field(String field)
Define the property name of the collection the conditional targets.
|
List<Conditional<?>> |
getConditionals() |
String |
getField() |
String |
getMatchStrategy() |
default String |
getType()
The type of conditional.
|
boolean |
isMatchIfEmpty() |
default C |
matchIfEmpty()
Marks this conditional as treating an empty collection as a match.
|
default C |
matchStrategy(String matchStrategy)
Define the match strategy.
|
default C |
notMatchIfEmpty()
Marks this conditional as treating an empty collection as NOT a match.
|
void |
setConditionals(List<Conditional<?>> conditionals) |
void |
setField(String field) |
void |
setMatchIfEmpty(boolean matchIfEmpty) |
void |
setMatchStrategy(String matchStrategy) |
self, when
static final String TYPE
default String getType()
Conditional
getType
in interface Conditional<C extends CollectionConditional<C>>
String getField()
String getMatchStrategy()
List<Conditional<?>> getConditionals()
boolean isMatchIfEmpty()
void setField(String field)
void setMatchStrategy(String matchStrategy)
void setConditionals(List<Conditional<?>> conditionals)
void setMatchIfEmpty(boolean matchIfEmpty)
default C field(String field)
field
- the property namedefault C matchStrategy(String matchStrategy)
CollectionConditional.CollectionConditionalMatchStrategy
.matchStrategy
- the match strategydefault C anyMatch()
default C allMatch()
default C conditional(Conditional<?>... conditionals)
conditionals
- the conditional(s)default C conditionals(List<Conditional<?>> conditionals)
conditionals
- the conditional(s)default C clearConditionals()
default C matchIfEmpty()
default C notMatchIfEmpty()
Copyright © 2021. All rights reserved.