org.kuali.rice.krad.datadictionary.validation.processor
Class RangeConstraintProcessor

java.lang.Object
  extended by org.kuali.rice.krad.datadictionary.validation.processor.MandatoryElementConstraintProcessor<RangeConstraint>
      extended by org.kuali.rice.krad.datadictionary.validation.processor.RangeConstraintProcessor
All Implemented Interfaces:
ConstraintProcessor<Object,RangeConstraint>

public class RangeConstraintProcessor
extends MandatoryElementConstraintProcessor<RangeConstraint>

RangeConstraintProcessor enforces range constraints - that is, constraints that keep a number or a date within a specific range

An attribute that is RangeConstrainable will expose a minimum and maximum value, and these will be validated against the passed value in the code below.

Author:
Kuali Rice Team (rice.collab@kuali.org)

Field Summary
 
Fields inherited from class org.kuali.rice.krad.datadictionary.validation.processor.MandatoryElementConstraintProcessor
dataDictionaryService, dateTimeService
 
Constructor Summary
RangeConstraintProcessor()
           
 
Method Summary
 Class<? extends Constraint> getConstraintType()
          gets the java class type of the constraint that this contraint processor handles
 String getName()
          gets a descriptive name of this constraint processor
 ProcessorResult process(DictionaryValidationResult result, Object value, RangeConstraint constraint, AttributeValueReader attributeValueReader)
          process the provided constraint
protected  ConstraintValidationResult processSingleRangeConstraint(DictionaryValidationResult result, Object value, RangeConstraint constraint, AttributeValueReader attributeValueReader)
          validates the value provided using RangeConstraint
protected  ConstraintValidationResult validateRange(DictionaryValidationResult result, Date value, RangeConstraint constraint, AttributeValueReader attributeValueReader)
          validates the date value using the range constraint provided
protected  ConstraintValidationResult validateRange(DictionaryValidationResult result, Number value, RangeConstraint constraint, AttributeValueReader attributeValueReader)
          validates the number value using the range constraint provided
 
Methods inherited from class org.kuali.rice.krad.datadictionary.validation.processor.MandatoryElementConstraintProcessor
getDataDictionaryService, getDateTimeService, isOptional, setDataDictionaryService, setDateTimeService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RangeConstraintProcessor

public RangeConstraintProcessor()
Method Detail

process

public ProcessorResult process(DictionaryValidationResult result,
                               Object value,
                               RangeConstraint constraint,
                               AttributeValueReader attributeValueReader)
                        throws AttributeValidationException
Description copied from interface: ConstraintProcessor
process the provided constraint

Parameters:
result - - holds dictionary validation results
value - - the value of the attribute
constraint - - the constraint to process
attributeValueReader - - - provides access to the attribute being validated
Returns:
the result of the constraint processing
Throws:
AttributeValidationException
See Also:
ConstraintProcessor.process(org.kuali.rice.krad.datadictionary.validation.result.DictionaryValidationResult, Object, org.kuali.rice.krad.datadictionary.validation.constraint.Constraint, org.kuali.rice.krad.datadictionary.validation.AttributeValueReader)

getName

public String getName()
Description copied from interface: ConstraintProcessor
gets a descriptive name of this constraint processor

e.g. @see CollectionSizeConstraintProcessor.CONSTRAINT_NAME

Returns:
a descriptive name

getConstraintType

public Class<? extends Constraint> getConstraintType()
Description copied from interface: ConstraintProcessor
gets the java class type of the constraint that this contraint processor handles

Returns:
an instance of Constraint
See Also:
ConstraintProcessor.getConstraintType()

processSingleRangeConstraint

protected ConstraintValidationResult processSingleRangeConstraint(DictionaryValidationResult result,
                                                                  Object value,
                                                                  RangeConstraint constraint,
                                                                  AttributeValueReader attributeValueReader)
                                                           throws AttributeValidationException
validates the value provided using RangeConstraint

Parameters:
result - - a holder for any already run validation results
value - - the value to validate
constraint - - the range constraint to use
attributeValueReader - - provides access to the attribute being validated
Returns:
the passed in result, updated with the results of the processing
Throws:
AttributeValidationException - if validation fails

validateRange

protected ConstraintValidationResult validateRange(DictionaryValidationResult result,
                                                   Date value,
                                                   RangeConstraint constraint,
                                                   AttributeValueReader attributeValueReader)
                                            throws IllegalArgumentException
validates the date value using the range constraint provided

Parameters:
result - - a holder for any already run validation results
value - - the value to validate
constraint - - the range constraint to use
attributeValueReader - - provides access to the attribute being validated
Returns:
the passed in result, updated with the results of the processing
Throws:
IllegalArgumentException

validateRange

protected ConstraintValidationResult validateRange(DictionaryValidationResult result,
                                                   Number value,
                                                   RangeConstraint constraint,
                                                   AttributeValueReader attributeValueReader)
                                            throws IllegalArgumentException
validates the number value using the range constraint provided

Parameters:
result - - a holder for any already run validation results
value - - the value to validate
constraint - - the range constraint to use
attributeValueReader - - provides access to the attribute being validated
Returns:
the passed in result, updated with the results of the processing
Throws:
IllegalArgumentException


Copyright © 2005–2014 The Kuali Foundation. All rights reserved.