|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.core.closure.support.AlgorithmsAccessor
org.springframework.rules.factory.Constraints
public class Constraints
A factory for easing the construction and composition of constraints.
Constructor Summary | |
---|---|
Constraints()
|
Method Summary | |
---|---|
And |
all(Constraint[] constraints)
Return the conjunction (all constraint) for all constraints. |
PropertyConstraint |
all(String propertyName,
Constraint[] constraints)
Apply an "all" value constraint to the provided bean property. |
And |
and(Constraint constraint1,
Constraint constraint2)
AND two constraints. |
Or |
any(Constraint[] constraints)
Return the disjunction (any constraint) for all constraints. |
PropertyConstraint |
any(String propertyName,
Constraint[] constraints)
Apply an "any" value constraint to the provided bean property. |
Constraint |
bind(BinaryConstraint constraint,
boolean parameter)
Bind the specified boolean parameter to the second
argument of the BinaryConstraint . |
Constraint |
bind(BinaryConstraint constraint,
double parameter)
Bind the specified double parameter to the second argument
of the BinaryConstraint . |
Constraint |
bind(BinaryConstraint constraint,
float parameter)
Bind the specified float parameter to the second argument
of the BinaryConstraint . |
Constraint |
bind(BinaryConstraint constraint,
int parameter)
Bind the specified int parameter to the second argument of
the BinaryConstraint . |
Constraint |
bind(BinaryConstraint constraint,
Object parameter)
Bind the specified parameter to the second argument of the BinaryConstraint . |
And |
conjunction()
Returns a new, empty conjunction prototype, capable of composing individual constraints where 'ALL' must test true. |
Or |
disjunction()
Returns a new, empty disjunction prototype, capable of composing individual constraints where 'ANY' must test true. |
Constraint |
eq(int value)
|
Constraint |
eq(Object value)
|
Constraint |
eq(Object value,
Comparator comparator)
|
PropertyConstraint |
eq(String propertyName,
Object propertyValue)
Apply a "equal to" constraint to a bean property. |
PropertyConstraint |
eq(String propertyName,
Object propertyValue,
Comparator comparator)
Apply a "equal to" constraint to a bean property. |
PropertyConstraint |
eqProperty(String propertyName,
String otherPropertyName)
Apply a "equal to" constraint to two bean properties. |
PropertyConstraint |
eqProperty(String propertyName,
String otherPropertyName,
Comparator comparator)
Apply a "equal to" constraint to two bean properties. |
XOr |
exclusiveDisjunction()
Returns a new, empty exclusive disjunction prototype, capable of composing individual constraints where only one must test true. |
Constraint |
gt(Comparable value)
|
Constraint |
gt(double value)
|
Constraint |
gt(float value)
|
Constraint |
gt(int value)
|
Constraint |
gt(long value)
|
Constraint |
gt(Object value,
Comparator comparator)
|
PropertyConstraint |
gt(String propertyName,
Comparable propertyValue)
Apply a "greater than" constraint to a bean property. |
Constraint |
gte(Comparable value)
|
Constraint |
gte(double value)
|
Constraint |
gte(float value)
|
Constraint |
gte(int value)
|
Constraint |
gte(long value)
|
Constraint |
gte(Object value,
Comparator comparator)
|
PropertyConstraint |
gte(String propertyName,
Comparable propertyValue)
Apply a "greater than equal to" constraint to a bean property. |
PropertyConstraint |
gteProperty(String propertyName,
String otherPropertyName)
Apply a "greater than or equal to" constraint to two properties. |
PropertyConstraint |
gteProperty(String propertyName,
String otherPropertyName,
Comparator comparator)
Apply a "greater than or equal to" constraint to two properties. |
PropertyConstraint |
gtProperty(String propertyName,
String otherPropertyName)
Apply a "greater than" constraint to two properties |
PropertyConstraint |
gtProperty(String propertyName,
String otherPropertyName,
Comparator comparator)
Apply a "greater than" constraint to two properties |
Constraint |
ifTrue(Constraint constraint,
Constraint mustAlsoBeTrue)
|
Constraint |
ifTrue(Constraint constraint,
Constraint mustAlsoBeTrue,
Constraint elseMustAlsoBeTrue)
|
Constraint |
ifTrue(Constraint constraint,
Constraint mustAlsoBeTrue,
Constraint elseMustAlsoBeTrue,
String type)
|
Constraint |
ifTrue(Constraint constraint,
Constraint mustAlsoBeTrue,
String type)
|
PropertyConstraint |
ifTrue(PropertyConstraint ifConstraint,
PropertyConstraint thenConstraint)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another. |
PropertyConstraint |
ifTrue(PropertyConstraint ifConstraint,
PropertyConstraint[] thenConstraints)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another. |
PropertyConstraint |
ifTrue(PropertyConstraint ifConstraint,
PropertyConstraint[] thenConstraints,
PropertyConstraint[] elseConstraints)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another. |
PropertyConstraint |
ifTrue(PropertyConstraint ifConstraint,
PropertyConstraint[] thenConstraints,
PropertyConstraint[] elseConstraints,
String type)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another. |
PropertyConstraint |
ifTrue(PropertyConstraint ifConstraint,
PropertyConstraint[] thenConstraints,
String type)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another. |
PropertyConstraint |
ifTrue(PropertyConstraint ifConstraint,
PropertyConstraint thenConstraint,
PropertyConstraint elseConstraint)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another. |
PropertyConstraint |
ifTrue(PropertyConstraint ifConstraint,
PropertyConstraint thenConstraint,
PropertyConstraint elseConstraint,
String type)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another. |
PropertyConstraint |
ifTrue(PropertyConstraint ifConstraint,
PropertyConstraint thenConstraint,
String type)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another. |
Constraint |
inGroup(int[] group)
Returns a 'in' group (or set) constraint. |
Constraint |
inGroup(Object[] group)
Returns a 'in' group (or set) constraint. |
Constraint |
inGroup(Set group)
Returns a 'in' group (or set) constraint. |
PropertyConstraint |
inGroup(String propertyName,
Object[] group)
Returns a 'in' group (or set) constraint appled to the provided property. |
PropertyConstraint |
inRange(String propertyName,
Comparable min,
Comparable max)
Apply a inclusive "range" constraint to a bean property. |
PropertyConstraint |
inRange(String propertyName,
Object min,
Object max,
Comparator comparator)
Apply a inclusive "range" constraint to a bean property. |
PropertyConstraint |
inRangeProperties(String propertyName,
String minPropertyName,
String maxPropertyName)
Apply a inclusive "range" constraint between two other properties to a bean property. |
PropertyConstraint |
inRangeProperties(String propertyName,
String minPropertyName,
String maxPropertyName,
Comparator comparator)
Apply a inclusive "range" constraint between two other properties to a bean property. |
static Constraints |
instance()
|
Constraint |
like(String encodedLikeString)
Returns a 'like' constraint. |
PropertyConstraint |
like(String property,
Like.LikeType likeType,
String value)
Return a 'like' constraint applied as a value constraint to the provided property. |
static void |
load(Constraints sharedInstance)
|
Constraint |
lt(Comparable value)
|
Constraint |
lt(Comparable value,
Comparator comparator)
|
Constraint |
lt(double value)
|
Constraint |
lt(float value)
|
Constraint |
lt(int value)
|
Constraint |
lt(long value)
|
PropertyConstraint |
lt(String propertyName,
Comparable propertyValue)
Apply a "less than" constraint to a bean property. |
Constraint |
lte(Comparable value)
|
Constraint |
lte(double value)
|
Constraint |
lte(float value)
|
Constraint |
lte(int value)
|
Constraint |
lte(long value)
|
Constraint |
lte(Object value,
Comparator comparator)
|
PropertyConstraint |
lte(String propertyName,
Comparable propertyValue)
Apply a "less than equal to" constraint to a bean property. |
PropertyConstraint |
lteProperty(String propertyName,
String otherPropertyName)
Apply a "less than or equal to" constraint to two properties. |
PropertyConstraint |
lteProperty(String propertyName,
String otherPropertyName,
Comparator comparator)
Apply a "less than or equal to" constraint to two properties. |
PropertyConstraint |
ltProperty(String propertyName,
String otherPropertyName)
Apply a "less than" constraint to two properties. |
PropertyConstraint |
ltProperty(String propertyName,
String otherPropertyName,
Comparator comparator)
Apply a "less than" constraint to two properties. |
Constraint |
maxLength(int maxLength)
Returns a maxlength constraint. |
Constraint |
method(Object target,
String methodName,
String constraintType)
Returns a constraint whose test is determined by a boolean method on a target object. |
Constraint |
minLength(int minLength)
Returns a minlength constraint. |
Constraint |
not(Constraint constraint)
Negate the specified constraint. |
PropertyConstraint |
not(PropertyConstraint e)
Negate a bean property expression. |
Or |
or(Constraint constraint1,
Constraint constraint2)
OR two constraints. |
Constraint |
present()
|
PropertyConstraint |
present(String propertyName)
Returns a present bean property expression. |
Constraint |
range(Comparable min,
Comparable max)
|
Constraint |
range(Comparable min,
Comparable max,
boolean inclusive)
|
Constraint |
range(double min,
double max)
|
Constraint |
range(float min,
float max)
|
Constraint |
range(int min,
int max)
|
Constraint |
range(long min,
long max)
|
Constraint |
range(Object min,
Object max,
Comparator comparator)
|
Constraint |
range(Object min,
Object max,
Comparator comparator,
boolean inclusive)
|
Constraint |
regexp(String regexp)
Creates a constraint backed by a regular expression. |
Constraint |
regexp(String regexp,
String type)
Creates a constraint backed by a regular expression, with a type for reporting. |
Constraint |
required()
Returns a required constraint. |
PropertyConstraint |
required(String property)
Returns a required bean property expression. |
Constraint |
testResultOf(Closure closure,
Constraint constraint)
Attaches a constraint that tests the result returned by evaluating the specified closure. |
PropertyConstraint |
unique(String propertyName)
Create a unique property value constraint that will test a collection of domain objects, returning true if all objects have unique values for the provided propertyName. |
PropertyConstraint |
value(String propertyName,
Constraint valueConstraint)
Attach a value constraint for the provided bean property. |
PropertyConstraint |
valueProperties(String propertyName,
BinaryConstraint constraint,
String otherPropertyName)
|
PropertyConstraint |
valueProperty(String propertyName,
BinaryConstraint constraint,
Object value)
|
Methods inherited from class org.springframework.core.closure.support.AlgorithmsAccessor |
---|
allTrue, allTrue, anyTrue, anyTrue, findAll, findAll, findFirst, findFirst, forEach, forEach, getAlgorithms |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Constraints()
Method Detail |
---|
public static Constraints instance()
public static void load(Constraints sharedInstance)
public Constraint bind(BinaryConstraint constraint, Object parameter)
BinaryConstraint
. The result is a Constraint
which will test a single variable argument against the constant
parameter.
constraint
- the binary constraint to bind toparameter
- the parameter value (constant)
public Constraint bind(BinaryConstraint constraint, int parameter)
int
parameter to the second argument of
the BinaryConstraint
. The result is a
Constraint
which will test a single variable argument
against the constant int
parameter.
constraint
- the binary constraint to bind toparameter
- the int
parameter value (constant)
public Constraint bind(BinaryConstraint constraint, float parameter)
float
parameter to the second argument
of the BinaryConstraint
. The result is a
Constraint
which will test a single variable argument
against the constant float
parameter.
constraint
- the binary constraint to bind toparameter
- the float
parameter value (constant)
public Constraint bind(BinaryConstraint constraint, double parameter)
double
parameter to the second argument
of the BinaryConstraint
. The result is a
Constraint
which will test a single variable argument
against the constant double
parameter.
constraint
- the binary constraint to bind toparameter
- the double
parameter value (constant)
public Constraint bind(BinaryConstraint constraint, boolean parameter)
boolean
parameter to the second
argument of the BinaryConstraint
. The result is a
Constraint
which will test a single variable argument
against the constant boolean
parameter.
constraint
- the binary constraint to bind toparameter
- the boolean
parameter value (constant)
public Constraint testResultOf(Closure closure, Constraint constraint)
closure
- the closureconstraint
- the constraint to test the closure result
public Constraint eq(Object value)
public Constraint eq(int value)
public Constraint eq(Object value, Comparator comparator)
public Constraint gt(Comparable value)
public Constraint gt(Object value, Comparator comparator)
public Constraint gt(int value)
public Constraint gt(long value)
public Constraint gt(float value)
public Constraint gt(double value)
public Constraint gte(Comparable value)
public Constraint gte(Object value, Comparator comparator)
public Constraint gte(int value)
public Constraint gte(long value)
public Constraint gte(float value)
public Constraint gte(double value)
public Constraint lt(Comparable value)
public Constraint lt(Comparable value, Comparator comparator)
public Constraint lt(int value)
public Constraint lt(long value)
public Constraint lt(float value)
public Constraint lt(double value)
public Constraint lte(Comparable value)
public Constraint lte(Object value, Comparator comparator)
public Constraint lte(int value)
public Constraint lte(long value)
public Constraint lte(float value)
public Constraint lte(double value)
public Constraint range(Comparable min, Comparable max)
public Constraint range(Comparable min, Comparable max, boolean inclusive)
public Constraint range(Object min, Object max, Comparator comparator)
public Constraint range(Object min, Object max, Comparator comparator, boolean inclusive)
public Constraint range(int min, int max)
public Constraint range(long min, long max)
public Constraint range(float min, float max)
public Constraint range(double min, double max)
public Constraint present()
public Constraint required()
public Constraint ifTrue(Constraint constraint, Constraint mustAlsoBeTrue)
public Constraint ifTrue(Constraint constraint, Constraint mustAlsoBeTrue, Constraint elseMustAlsoBeTrue)
public Constraint ifTrue(Constraint constraint, Constraint mustAlsoBeTrue, String type)
public Constraint ifTrue(Constraint constraint, Constraint mustAlsoBeTrue, Constraint elseMustAlsoBeTrue, String type)
public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, PropertyConstraint thenConstraint)
ConditionalPropertyConstraint
public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, PropertyConstraint thenConstraint, String type)
ConditionalPropertyConstraint
public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, PropertyConstraint thenConstraint, PropertyConstraint elseConstraint)
ConditionalPropertyConstraint
public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, PropertyConstraint thenConstraint, PropertyConstraint elseConstraint, String type)
ConditionalPropertyConstraint
public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, PropertyConstraint[] thenConstraints)
ConditionalPropertyConstraint
public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, PropertyConstraint[] thenConstraints, String type)
ConditionalPropertyConstraint
public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, PropertyConstraint[] thenConstraints, PropertyConstraint[] elseConstraints)
ConditionalPropertyConstraint
public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, PropertyConstraint[] thenConstraints, PropertyConstraint[] elseConstraints, String type)
ConditionalPropertyConstraint
public Constraint maxLength(int maxLength)
maxLength
- The maximum length in characters.
public Constraint minLength(int minLength)
minLength
- The minimum length in characters.
public Constraint like(String encodedLikeString)
encodedLikeString
- the likeString
public Constraint regexp(String regexp)
regexp
- The regular expression string.
public Constraint regexp(String regexp, String type)
regexp
- The regular expression string.
public Constraint method(Object target, String methodName, String constraintType)
targetObject
- The targetObjectmethodName
- The method name
public Constraint inGroup(Set group)
group
- the group items
public Constraint inGroup(Object[] group)
group
- the group items
public Constraint inGroup(int[] group)
group
- the group items
public And and(Constraint constraint1, Constraint constraint2)
constraint1
- the first constraintconstraint2
- the second constraint
public And all(Constraint[] constraints)
constraints
- the constraints
public And conjunction()
public Or or(Constraint constraint1, Constraint constraint2)
constraint1
- the first constraintconstraint2
- the second constraint
public Or any(Constraint[] constraints)
constraints
- the constraints
public Or disjunction()
public XOr exclusiveDisjunction()
public Constraint not(Constraint constraint)
constraint
- The constraint to negate
public PropertyConstraint value(String propertyName, Constraint valueConstraint)
propertyName
- the bean property namevalueConstraint
- the value constraint
public PropertyConstraint present(String propertyName)
public PropertyConstraint required(String property)
public PropertyConstraint like(String property, Like.LikeType likeType, String value)
property
- The property to constrainlikeType
- The like typevalue
- The like string value to match
public PropertyConstraint inGroup(String propertyName, Object[] group)
propertyName
- the propertygroup
- the group items
public PropertyConstraint all(String propertyName, Constraint[] constraints)
propertyName
- The bean property nameconstraints
- The constraints that form a all conjunction
public PropertyConstraint any(String propertyName, Constraint[] constraints)
propertyName
- The bean property nameconstraints
- The constraints that form a all disjunction
public PropertyConstraint not(PropertyConstraint e)
e
- the expression to negate
public PropertyConstraint valueProperty(String propertyName, BinaryConstraint constraint, Object value)
public PropertyConstraint eq(String propertyName, Object propertyValue)
propertyName
- The first propertypropertyValue
- The constraint value
public PropertyConstraint eq(String propertyName, Object propertyValue, Comparator comparator)
propertyName
- The first propertypropertyValue
- The constraint valuecomparator
- the comparator to use while comparing the values
public PropertyConstraint gt(String propertyName, Comparable propertyValue)
propertyName
- The first propertypropertyValue
- The constraint value
public PropertyConstraint gte(String propertyName, Comparable propertyValue)
propertyName
- The first propertypropertyValue
- The constraint value
public PropertyConstraint lt(String propertyName, Comparable propertyValue)
propertyName
- The first propertypropertyValue
- The constraint value
public PropertyConstraint lte(String propertyName, Comparable propertyValue)
propertyName
- The first propertypropertyValue
- The constraint value
public PropertyConstraint valueProperties(String propertyName, BinaryConstraint constraint, String otherPropertyName)
public PropertyConstraint eqProperty(String propertyName, String otherPropertyName, Comparator comparator)
propertyName
- The first propertyotherPropertyName
- The other propertycomparator
- the comparator to use while comparing the values
public PropertyConstraint gtProperty(String propertyName, String otherPropertyName, Comparator comparator)
propertyName
- The first propertyotherPropertyName
- The other propertycomparator
- the comparator to use while comparing the values
public PropertyConstraint gteProperty(String propertyName, String otherPropertyName, Comparator comparator)
propertyName
- The first propertyotherPropertyName
- The other propertycomparator
- the comparator to use while comparing the values
public PropertyConstraint ltProperty(String propertyName, String otherPropertyName, Comparator comparator)
propertyName
- The first propertyotherPropertyName
- The other propertycomparator
- the comparator to use while comparing the values
public PropertyConstraint lteProperty(String propertyName, String otherPropertyName, Comparator comparator)
propertyName
- The first propertyotherPropertyName
- The other propertycomparator
- the comparator to use while comparing the values
public PropertyConstraint inRange(String propertyName, Object min, Object max, Comparator comparator)
propertyName
- the property with the range constraint.min
- the low edge of the rangemax
- the high edge of the rangecomparator
- the comparator to use while comparing the values
public PropertyConstraint inRangeProperties(String propertyName, String minPropertyName, String maxPropertyName, Comparator comparator)
propertyName
- the property with the range constraint.minPropertyName
- the low edge of the rangemaxPropertyName
- the high edge of the rangecomparator
- the comparator to use while comparing the values
public PropertyConstraint eqProperty(String propertyName, String otherPropertyName)
propertyName
- The first propertyotherPropertyName
- The other property
public PropertyConstraint gtProperty(String propertyName, String otherPropertyName)
propertyName
- The first propertyotherPropertyName
- The other property
public PropertyConstraint gteProperty(String propertyName, String otherPropertyName)
propertyName
- The first propertyotherPropertyName
- The other property
public PropertyConstraint ltProperty(String propertyName, String otherPropertyName)
propertyName
- The first propertyotherPropertyName
- The other property
public PropertyConstraint lteProperty(String propertyName, String otherPropertyName)
propertyName
- The first propertyotherPropertyName
- The other property
public PropertyConstraint inRange(String propertyName, Comparable min, Comparable max)
propertyName
- the property with the range constraint.min
- the low edge of the rangemax
- the high edge of the range
public PropertyConstraint inRangeProperties(String propertyName, String minPropertyName, String maxPropertyName)
propertyName
- the property with the range constraint.minPropertyName
- the low edge of the rangemaxPropertyName
- the high edge of the range
public PropertyConstraint unique(String propertyName)
propertyName
- The property name
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |