org.springframework.rules.support
Class DefaultRulesSource

java.lang.Object
  extended by org.springframework.core.closure.support.AlgorithmsAccessor
      extended by org.springframework.rules.constraint.ConstraintsAccessor
          extended by org.springframework.rules.support.DefaultRulesSource
All Implemented Interfaces:
RulesSource
Direct Known Subclasses:
AttributesRulesSource, PetClinicValidationRulesSource, SimpleValidationRulesSource

public class DefaultRulesSource
extends ConstraintsAccessor
implements RulesSource

A default rules source implementation which is simply a in-memory registry for bean validation rules backed by a map.

Author:
Keith Donald

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
DefaultRulesSource()
           
 
Method Summary
 void addRules(Rules rules)
          Add or update the rules for a single bean class.
 void addRules(String contextId, Rules rules)
           
 PropertyConstraint getPropertyConstraint(Class bean, String propertyName)
          Return the validation rules for the provided bean property.
 PropertyConstraint getPropertyConstraint(Class bean, String propertyName, String contextId)
           
 Rules getRules(Class bean)
          Return the validation rules for the provided bean.
 Rules getRules(Class beanType, String contextId)
           
 void setRules(List rules)
          Set the list of rules retrievable by this source, where each item in the list is a Rules object which maintains validation rules for a bean class.
 String toString()
           
 
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
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

DefaultRulesSource

public DefaultRulesSource()
Method Detail

addRules

public void addRules(Rules rules)
Add or update the rules for a single bean class.

Parameters:
rules - The rules.

addRules

public void addRules(String contextId,
                     Rules rules)

setRules

public void setRules(List rules)
Set the list of rules retrievable by this source, where each item in the list is a Rules object which maintains validation rules for a bean class.

Parameters:
rules - The list of rules.

getRules

public Rules getRules(Class bean)
Description copied from interface: RulesSource
Return the validation rules for the provided bean.

Specified by:
getRules in interface RulesSource
Returns:
The validation rules, or null if none exist.

getRules

public Rules getRules(Class beanType,
                      String contextId)
Specified by:
getRules in interface RulesSource

getPropertyConstraint

public PropertyConstraint getPropertyConstraint(Class bean,
                                                String propertyName)
Description copied from interface: RulesSource
Return the validation rules for the provided bean property.

Specified by:
getPropertyConstraint in interface RulesSource
Parameters:
bean - the bean class
propertyName - the bean propertyName
Returns:
The validation rules, or null if none exist.

getPropertyConstraint

public PropertyConstraint getPropertyConstraint(Class bean,
                                                String propertyName,
                                                String contextId)
Specified by:
getPropertyConstraint in interface RulesSource

toString

public String toString()
Overrides:
toString in class Object


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