org.springframework.rules.factory
Class Constraints

java.lang.Object
  extended by org.springframework.core.closure.support.AlgorithmsAccessor
      extended by org.springframework.rules.factory.Constraints

public class Constraints
extends AlgorithmsAccessor

A factory for easing the construction and composition of constraints.

Author:
Keith Donald

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

Constraints

public Constraints()
Method Detail

instance

public static Constraints instance()

load

public static void load(Constraints sharedInstance)

bind

public Constraint bind(BinaryConstraint constraint,
                       Object parameter)
Bind the specified parameter to the second argument of the BinaryConstraint. The result is a Constraint which will test a single variable argument against the constant parameter.

Parameters:
constraint - the binary constraint to bind to
parameter - the parameter value (constant)
Returns:
The constraint

bind

public Constraint bind(BinaryConstraint constraint,
                       int parameter)
Bind the specified 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.

Parameters:
constraint - the binary constraint to bind to
parameter - the int parameter value (constant)
Returns:
The constraint

bind

public Constraint bind(BinaryConstraint constraint,
                       float parameter)
Bind the specified 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.

Parameters:
constraint - the binary constraint to bind to
parameter - the float parameter value (constant)
Returns:
The constraint

bind

public Constraint bind(BinaryConstraint constraint,
                       double parameter)
Bind the specified 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.

Parameters:
constraint - the binary constraint to bind to
parameter - the double parameter value (constant)
Returns:
The constraint

bind

public Constraint bind(BinaryConstraint constraint,
                       boolean parameter)
Bind the specified 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.

Parameters:
constraint - the binary constraint to bind to
parameter - the boolean parameter value (constant)
Returns:
The constraint

testResultOf

public Constraint testResultOf(Closure closure,
                               Constraint constraint)
Attaches a constraint that tests the result returned by evaluating the specified closure. This effectively attaches a constraint on the closure return value.

Parameters:
closure - the closure
constraint - the constraint to test the closure result
Returns:
The testing constraint, which on the call to test(o) first evaluates 'o' using the closure and then tests the result.

eq

public Constraint eq(Object value)

eq

public Constraint eq(int value)

eq

public Constraint eq(Object value,
                     Comparator comparator)

gt

public Constraint gt(Comparable value)

gt

public Constraint gt(Object value,
                     Comparator comparator)

gt

public Constraint gt(int value)

gt

public Constraint gt(long value)

gt

public Constraint gt(float value)

gt

public Constraint gt(double value)

gte

public Constraint gte(Comparable value)

gte

public Constraint gte(Object value,
                      Comparator comparator)

gte

public Constraint gte(int value)

gte

public Constraint gte(long value)

gte

public Constraint gte(float value)

gte

public Constraint gte(double value)

lt

public Constraint lt(Comparable value)

lt

public Constraint lt(Comparable value,
                     Comparator comparator)

lt

public Constraint lt(int value)

lt

public Constraint lt(long value)

lt

public Constraint lt(float value)

lt

public Constraint lt(double value)

lte

public Constraint lte(Comparable value)

lte

public Constraint lte(Object value,
                      Comparator comparator)

lte

public Constraint lte(int value)

lte

public Constraint lte(long value)

lte

public Constraint lte(float value)

lte

public Constraint lte(double value)

range

public Constraint range(Comparable min,
                        Comparable max)

range

public Constraint range(Comparable min,
                        Comparable max,
                        boolean inclusive)

range

public Constraint range(Object min,
                        Object max,
                        Comparator comparator)

range

public Constraint range(Object min,
                        Object max,
                        Comparator comparator,
                        boolean inclusive)

range

public Constraint range(int min,
                        int max)

range

public Constraint range(long min,
                        long max)

range

public Constraint range(float min,
                        float max)

range

public Constraint range(double min,
                        double max)

present

public Constraint present()

required

public Constraint required()
Returns a required constraint.

Returns:
The required constraint instance.

ifTrue

public Constraint ifTrue(Constraint constraint,
                         Constraint mustAlsoBeTrue)

ifTrue

public Constraint ifTrue(Constraint constraint,
                         Constraint mustAlsoBeTrue,
                         Constraint elseMustAlsoBeTrue)

ifTrue

public Constraint ifTrue(Constraint constraint,
                         Constraint mustAlsoBeTrue,
                         String type)

ifTrue

public Constraint ifTrue(Constraint constraint,
                         Constraint mustAlsoBeTrue,
                         Constraint elseMustAlsoBeTrue,
                         String type)

ifTrue

public PropertyConstraint ifTrue(PropertyConstraint ifConstraint,
                                 PropertyConstraint thenConstraint)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another.

See Also:
ConditionalPropertyConstraint

ifTrue

public PropertyConstraint ifTrue(PropertyConstraint ifConstraint,
                                 PropertyConstraint thenConstraint,
                                 String type)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another.

See Also:
ConditionalPropertyConstraint

ifTrue

public PropertyConstraint ifTrue(PropertyConstraint ifConstraint,
                                 PropertyConstraint thenConstraint,
                                 PropertyConstraint elseConstraint)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another.

See Also:
ConditionalPropertyConstraint

ifTrue

public PropertyConstraint ifTrue(PropertyConstraint ifConstraint,
                                 PropertyConstraint thenConstraint,
                                 PropertyConstraint elseConstraint,
                                 String type)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another.

See Also:
ConditionalPropertyConstraint

ifTrue

public PropertyConstraint ifTrue(PropertyConstraint ifConstraint,
                                 PropertyConstraint[] thenConstraints)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another.

See Also:
ConditionalPropertyConstraint

ifTrue

public PropertyConstraint ifTrue(PropertyConstraint ifConstraint,
                                 PropertyConstraint[] thenConstraints,
                                 String type)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another.

See Also:
ConditionalPropertyConstraint

ifTrue

public PropertyConstraint ifTrue(PropertyConstraint ifConstraint,
                                 PropertyConstraint[] thenConstraints,
                                 PropertyConstraint[] elseConstraints)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another.

See Also:
ConditionalPropertyConstraint

ifTrue

public PropertyConstraint ifTrue(PropertyConstraint ifConstraint,
                                 PropertyConstraint[] thenConstraints,
                                 PropertyConstraint[] elseConstraints,
                                 String type)
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another.

See Also:
ConditionalPropertyConstraint

maxLength

public Constraint maxLength(int maxLength)
Returns a maxlength constraint.

Parameters:
maxLength - The maximum length in characters.
Returns:
The configured maxlength constraint.

minLength

public Constraint minLength(int minLength)
Returns a minlength constraint.

Parameters:
minLength - The minimum length in characters.
Returns:
The configured minlength constraint.

like

public Constraint like(String encodedLikeString)
Returns a 'like' constraint.

Parameters:
encodedLikeString - the likeString
Returns:
The Like constraint.

regexp

public Constraint regexp(String regexp)
Creates a constraint backed by a regular expression.

Parameters:
regexp - The regular expression string.
Returns:
The constraint.

regexp

public Constraint regexp(String regexp,
                         String type)
Creates a constraint backed by a regular expression, with a type for reporting.

Parameters:
regexp - The regular expression string.
Returns:
The constraint.

method

public Constraint method(Object target,
                         String methodName,
                         String constraintType)
Returns a constraint whose test is determined by a boolean method on a target object.

Parameters:
targetObject - The targetObject
methodName - The method name
Returns:
The constraint.

inGroup

public Constraint inGroup(Set group)
Returns a 'in' group (or set) constraint.

Parameters:
group - the group items
Returns:
The InGroup constraint

inGroup

public Constraint inGroup(Object[] group)
Returns a 'in' group (or set) constraint.

Parameters:
group - the group items
Returns:
The InGroup constraint.

inGroup

public Constraint inGroup(int[] group)
Returns a 'in' group (or set) constraint.

Parameters:
group - the group items
Returns:
The InGroup constraint.

and

public And and(Constraint constraint1,
               Constraint constraint2)
AND two constraints.

Parameters:
constraint1 - the first constraint
constraint2 - the second constraint
Returns:
The compound AND constraint

all

public And all(Constraint[] constraints)
Return the conjunction (all constraint) for all constraints.

Parameters:
constraints - the constraints
Returns:
The compound AND constraint

conjunction

public And conjunction()
Returns a new, empty conjunction prototype, capable of composing individual constraints where 'ALL' must test true.

Returns:
the UnaryAnd

or

public Or or(Constraint constraint1,
             Constraint constraint2)
OR two constraints.

Parameters:
constraint1 - the first constraint
constraint2 - the second constraint
Returns:
The compound OR constraint

any

public Or any(Constraint[] constraints)
Return the disjunction (any constraint) for all constraints.

Parameters:
constraints - the constraints
Returns:
The compound AND constraint

disjunction

public Or disjunction()
Returns a new, empty disjunction prototype, capable of composing individual constraints where 'ANY' must test true.

Returns:
the UnaryOr

exclusiveDisjunction

public XOr exclusiveDisjunction()
Returns a new, empty exclusive disjunction prototype, capable of composing individual constraints where only one must test true.

Returns:
the UnaryXOr

not

public Constraint not(Constraint constraint)
Negate the specified constraint.

Parameters:
constraint - The constraint to negate
Returns:
The negated constraint.

value

public PropertyConstraint value(String propertyName,
                                Constraint valueConstraint)
Attach a value constraint for the provided bean property.

Parameters:
propertyName - the bean property name
valueConstraint - the value constraint
Returns:
The bean property expression that tests the constraint

present

public PropertyConstraint present(String propertyName)
Returns a present bean property expression.

Returns:
The present constraint instance.

required

public PropertyConstraint required(String property)
Returns a required bean property expression.

Returns:
The required constraint instance.

like

public PropertyConstraint like(String property,
                               Like.LikeType likeType,
                               String value)
Return a 'like' constraint applied as a value constraint to the provided property.

Parameters:
property - The property to constrain
likeType - The like type
value - The like string value to match
Returns:
The Like constraint

inGroup

public PropertyConstraint inGroup(String propertyName,
                                  Object[] group)
Returns a 'in' group (or set) constraint appled to the provided property.

Parameters:
propertyName - the property
group - the group items
Returns:
The InGroup constraint.

all

public PropertyConstraint all(String propertyName,
                              Constraint[] constraints)
Apply an "all" value constraint to the provided bean property.

Parameters:
propertyName - The bean property name
constraints - The constraints that form a all conjunction
Returns:

any

public PropertyConstraint any(String propertyName,
                              Constraint[] constraints)
Apply an "any" value constraint to the provided bean property.

Parameters:
propertyName - The bean property name
constraints - The constraints that form a all disjunction
Returns:

not

public PropertyConstraint not(PropertyConstraint e)
Negate a bean property expression.

Parameters:
e - the expression to negate
Returns:
The negated expression

valueProperty

public PropertyConstraint valueProperty(String propertyName,
                                        BinaryConstraint constraint,
                                        Object value)

eq

public PropertyConstraint eq(String propertyName,
                             Object propertyValue)
Apply a "equal to" constraint to a bean property.

Parameters:
propertyName - The first property
propertyValue - The constraint value
Returns:
The constraint

eq

public PropertyConstraint eq(String propertyName,
                             Object propertyValue,
                             Comparator comparator)
Apply a "equal to" constraint to a bean property.

Parameters:
propertyName - The first property
propertyValue - The constraint value
comparator - the comparator to use while comparing the values
Returns:
The constraint
Since:
0.3.0

gt

public PropertyConstraint gt(String propertyName,
                             Comparable propertyValue)
Apply a "greater than" constraint to a bean property.

Parameters:
propertyName - The first property
propertyValue - The constraint value
Returns:
The constraint

gte

public PropertyConstraint gte(String propertyName,
                              Comparable propertyValue)
Apply a "greater than equal to" constraint to a bean property.

Parameters:
propertyName - The first property
propertyValue - The constraint value
Returns:
The constraint

lt

public PropertyConstraint lt(String propertyName,
                             Comparable propertyValue)
Apply a "less than" constraint to a bean property.

Parameters:
propertyName - The first property
propertyValue - The constraint value
Returns:
The constraint

lte

public PropertyConstraint lte(String propertyName,
                              Comparable propertyValue)
Apply a "less than equal to" constraint to a bean property.

Parameters:
propertyName - The first property
propertyValue - The constraint value
Returns:
The constraint

valueProperties

public PropertyConstraint valueProperties(String propertyName,
                                          BinaryConstraint constraint,
                                          String otherPropertyName)

eqProperty

public PropertyConstraint eqProperty(String propertyName,
                                     String otherPropertyName,
                                     Comparator comparator)
Apply a "equal to" constraint to two bean properties.

Parameters:
propertyName - The first property
otherPropertyName - The other property
comparator - the comparator to use while comparing the values
Returns:
The constraint
Since:
0.3.0

gtProperty

public PropertyConstraint gtProperty(String propertyName,
                                     String otherPropertyName,
                                     Comparator comparator)
Apply a "greater than" constraint to two properties

Parameters:
propertyName - The first property
otherPropertyName - The other property
comparator - the comparator to use while comparing the values
Returns:
The constraint
Since:
0.3.0

gteProperty

public PropertyConstraint gteProperty(String propertyName,
                                      String otherPropertyName,
                                      Comparator comparator)
Apply a "greater than or equal to" constraint to two properties.

Parameters:
propertyName - The first property
otherPropertyName - The other property
comparator - the comparator to use while comparing the values
Returns:
The constraint
Since:
0.3.0

ltProperty

public PropertyConstraint ltProperty(String propertyName,
                                     String otherPropertyName,
                                     Comparator comparator)
Apply a "less than" constraint to two properties.

Parameters:
propertyName - The first property
otherPropertyName - The other property
comparator - the comparator to use while comparing the values
Returns:
The constraint
Since:
0.3.0

lteProperty

public PropertyConstraint lteProperty(String propertyName,
                                      String otherPropertyName,
                                      Comparator comparator)
Apply a "less than or equal to" constraint to two properties.

Parameters:
propertyName - The first property
otherPropertyName - The other property
comparator - the comparator to use while comparing the values
Returns:
The constraint
Since:
0.3.0

inRange

public PropertyConstraint inRange(String propertyName,
                                  Object min,
                                  Object max,
                                  Comparator comparator)
Apply a inclusive "range" constraint to a bean property.

Parameters:
propertyName - the property with the range constraint.
min - the low edge of the range
max - the high edge of the range
comparator - the comparator to use while comparing the values
Returns:
The range constraint constraint
Since:
0.3.0

inRangeProperties

public PropertyConstraint inRangeProperties(String propertyName,
                                            String minPropertyName,
                                            String maxPropertyName,
                                            Comparator comparator)
Apply a inclusive "range" constraint between two other properties to a bean property.

Parameters:
propertyName - the property with the range constraint.
minPropertyName - the low edge of the range
maxPropertyName - the high edge of the range
comparator - the comparator to use while comparing the values
Returns:
The range constraint constraint
Since:
0.3.0

eqProperty

public PropertyConstraint eqProperty(String propertyName,
                                     String otherPropertyName)
Apply a "equal to" constraint to two bean properties.

Parameters:
propertyName - The first property
otherPropertyName - The other property
Returns:
The constraint

gtProperty

public PropertyConstraint gtProperty(String propertyName,
                                     String otherPropertyName)
Apply a "greater than" constraint to two properties

Parameters:
propertyName - The first property
otherPropertyName - The other property
Returns:
The constraint

gteProperty

public PropertyConstraint gteProperty(String propertyName,
                                      String otherPropertyName)
Apply a "greater than or equal to" constraint to two properties.

Parameters:
propertyName - The first property
otherPropertyName - The other property
Returns:
The constraint

ltProperty

public PropertyConstraint ltProperty(String propertyName,
                                     String otherPropertyName)
Apply a "less than" constraint to two properties.

Parameters:
propertyName - The first property
otherPropertyName - The other property
Returns:
The constraint

lteProperty

public PropertyConstraint lteProperty(String propertyName,
                                      String otherPropertyName)
Apply a "less than or equal to" constraint to two properties.

Parameters:
propertyName - The first property
otherPropertyName - The other property
Returns:
The constraint

inRange

public PropertyConstraint inRange(String propertyName,
                                  Comparable min,
                                  Comparable max)
Apply a inclusive "range" constraint to a bean property.

Parameters:
propertyName - the property with the range constraint.
min - the low edge of the range
max - the high edge of the range
Returns:
The range constraint constraint

inRangeProperties

public PropertyConstraint inRangeProperties(String propertyName,
                                            String minPropertyName,
                                            String maxPropertyName)
Apply a inclusive "range" constraint between two other properties to a bean property.

Parameters:
propertyName - the property with the range constraint.
minPropertyName - the low edge of the range
maxPropertyName - the high edge of the range
Returns:
The range constraint constraint

unique

public 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.

Parameters:
propertyName - The property name
Returns:
The constraint


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.