org.springframework.rules
Class Rules

java.lang.Object
  extended by org.springframework.core.closure.support.AlgorithmsAccessor
      extended by org.springframework.rules.constraint.ConstraintsAccessor
          extended by org.springframework.rules.Rules
All Implemented Interfaces:
InitializingBean, Constraint, PropertyConstraintProvider, Validator

public class Rules
extends ConstraintsAccessor
implements Constraint, PropertyConstraintProvider, Validator, InitializingBean

A factory for creating rules.

Author:
Keith Donald

Constructor Summary
Rules()
           
Rules(Class domainObjectClass)
           
Rules(Class domainObjectClass, Map propertiesConstraints)
           
 
Method Summary
 void add(CompoundConstraint compoundPredicate)
          Adds the provided compound predicate, composed of BeanPropertyExpression objects, as a bean property constraint.
 Rules add(PropertyConstraint constraint)
          Adds the provided bean property expression (constraint) to the list of constraints for the constrained property.
 void add(String propertyName, Constraint valueConstraint)
          Adds a value constraint for the specified property.
 void add(String propertyName, Constraint[] valueConstraints)
          Adds a value constraint for the specified property.
 void addMaxLength(String propertyName, int maxLength)
           
 void addMinLength(String propertyName, int minLength)
           
 void addRange(String propertyName, Range range)
           
 void addRequired(String propertyName)
           
 void addRequired(String propertyName, Constraint otherConstraints)
           
 void afterPropertiesSet()
           
 Class getDomainObjectType()
           
 PropertyConstraint getPropertyConstraint(String property)
          Returns the constraint on the given property.
protected  void initRules()
           
 Iterator iterator()
           
 void setDomainObjectType(Class domainObjectType)
           
 void setPropertiesConstraints(Map propertiesConstraints)
           
 boolean supports(Class type)
           
 boolean test(Object bean)
          Test the provided argument against this predicate's condition.
 String toString()
           
 void validate(Object bean, Errors errors)
           
 
Methods inherited from class org.springframework.rules.constraint.ConstraintsAccessor
all, all, and, any, any, bind, bind, bind, bind, bind, conjunction, disjunction, eq, eq, eq, eq, eq, eqProperty, eqProperty, getConstraints, gt, gt, gt, gt, gt, gt, gt, gte, gte, gte, gte, gte, gte, gte, gteProperty, gteProperty, gtProperty, gtProperty, ifTrue, ifTrueElse, inGroup, inGroup, inGroup, inRange, inRange, inRangeProperties, inRangeProperties, like, like, lt, lt, lt, lt, lt, lt, lt, lte, lte, lte, lte, lte, lte, lte, lteProperty, lteProperty, ltProperty, ltProperty, maxLength, method, minLength, not, not, or, present, present, range, range, range, range, range, range, range, regexp, regexp, required, required, testResultOf, unique, 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, wait, wait, wait
 

Constructor Detail

Rules

public Rules()

Rules

public Rules(Class domainObjectClass)

Rules

public Rules(Class domainObjectClass,
             Map propertiesConstraints)
Method Detail

setDomainObjectType

public void setDomainObjectType(Class domainObjectType)

getDomainObjectType

public Class getDomainObjectType()

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface InitializingBean

initRules

protected void initRules()

setPropertiesConstraints

public void setPropertiesConstraints(Map propertiesConstraints)

getPropertyConstraint

public PropertyConstraint getPropertyConstraint(String property)
Description copied from interface: PropertyConstraintProvider
Returns the constraint on the given property.

Specified by:
getPropertyConstraint in interface PropertyConstraintProvider

iterator

public Iterator iterator()

add

public Rules add(PropertyConstraint constraint)
Adds the provided bean property expression (constraint) to the list of constraints for the constrained property.

Parameters:
constraint - the bean property expression
Returns:
this, to support chaining.

add

public void add(String propertyName,
                Constraint valueConstraint)
Adds a value constraint for the specified property.

Parameters:
propertyName - The property name.
valueConstraint - The value constraint.

add

public void add(String propertyName,
                Constraint[] valueConstraints)
Adds a value constraint for the specified property.

Parameters:
propertyName - The property name.
valueConstraint - The value constraint.

addRequired

public void addRequired(String propertyName)

addRequired

public void addRequired(String propertyName,
                        Constraint otherConstraints)

addMaxLength

public void addMaxLength(String propertyName,
                         int maxLength)

addMinLength

public void addMinLength(String propertyName,
                         int minLength)

addRange

public void addRange(String propertyName,
                     Range range)

add

public void add(CompoundConstraint compoundPredicate)
Adds the provided compound predicate, composed of BeanPropertyExpression objects, as a bean property constraint.

Parameters:
compoundPredicate -

test

public boolean test(Object bean)
Description copied from interface: Constraint
Test the provided argument against this predicate's condition.

Specified by:
test in interface Constraint
Parameters:
bean - the argument value
Returns:
true if the condition was satisfied, false otherwise

supports

public boolean supports(Class type)
Specified by:
supports in interface Validator

validate

public void validate(Object bean,
                     Errors errors)
Specified by:
validate in interface Validator

toString

public String toString()
Overrides:
toString in class Object


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