Interface Condition<T>
- Type Parameters:
T- The type of the value to be tested.
- All Known Implementing Classes:
Condition.AllOf, Condition.AnyOf, Condition.One
public interface Condition<T>
Represents a logical condition tree that can be evaluated against a
Predicate.
This interface supports three primary types of logic:
- One: A single value that must satisfy the predicate.
- AnyOf (OR): A collection of conditions where at least one must satisfy the predicate.
- AllOf (AND): A collection of conditions where all must satisfy the predicate.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordA condition implementation that represents a logical AND.static final recordA condition implementation that represents a logical OR.static final recordA condition implementation that wraps a single value. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Condition<T> Creates an AND-gate condition (AllOf) from a variable number of conditions.static <T> Condition<T> Creates an AND-gate condition (AllOf) from a list of conditions.static <T> Condition<T> Creates an OR-gate condition (AnyOf) from a variable number of conditions.static <T> Condition<T> Creates an OR-gate condition (AnyOf) from a list of conditions.Creates a codec for serializing and deserializing recursive condition trees.static <T> Condition<T> one(T value) Creates a simple condition representing a single value.booleanEvaluates this condition against the provided predicate.
-
Method Details
-
test
-
one
Creates a simple condition representing a single value.- Type Parameters:
T- The type of the value.- Parameters:
value- The value to be wrapped.- Returns:
- A new
Condition.Onecondition.
-
anyOf
Creates an OR-gate condition (AnyOf) from a variable number of conditions.- Type Parameters:
T- The type of the values.- Parameters:
conditions- The conditions to evaluate.- Returns:
- A new
Condition.AnyOfcondition.
-
anyOf
Creates an OR-gate condition (AnyOf) from a list of conditions.- Type Parameters:
T- The type of the values.- Parameters:
conditions- The list of conditions to evaluate.- Returns:
- A new
Condition.AnyOfcondition.
-
allOf
Creates an AND-gate condition (AllOf) from a variable number of conditions.- Type Parameters:
T- The type of the values.- Parameters:
conditions- The conditions to evaluate.- Returns:
- A new
Condition.AllOfcondition.
-
allOf
Creates an AND-gate condition (AllOf) from a list of conditions.- Type Parameters:
T- The type of the values.- Parameters:
conditions- The list of conditions to evaluate.- Returns:
- A new
Condition.AllOfcondition.
-
codec
Creates a codec for serializing and deserializing recursive condition trees.The serialized format supports raw values (interpreted as
One) or objects containingany_oforall_ofkeys.
-