Interface ConstraintProcessor<T,C extends Constraint>
- Type Parameters:
T- constrainable data typeC- constraint type
- All Known Subinterfaces:
CollectionConstraintProcessor<T,C>
- All Known Implementing Classes:
BasePrerequisiteConstraintProcessor,CaseConstraintProcessor,CollectionSizeConstraintProcessor,DataTypeConstraintProcessor,ExistenceConstraintProcessor,LengthConstraintProcessor,MandatoryElementConstraintProcessor,MustOccurConstraintProcessor,OptionalElementConstraintProcessor,PrerequisiteConstraintProcessor,RangeConstraintProcessor,SimpleConstraintProcessor,ValidCharactersConstraintProcessor
public interface ConstraintProcessor<T,C extends Constraint>
ConstraintProcessor must be implemented by constraint processors, which validate individual constraints in the
data dictionary
The idea is that each constraint has its own processor, and that the validation service can be configured via dependency injection with a list of processors. This gives institutions the ability to easily modify how validation should be handled and to add arbitrary new constraints and constraint processors.
An alternative might have been to put the process() method into the Constraint marker interface and have each Constraint define its own processing, but that would have forced business logic into what are naturally API classes (classes that implement Constraint). This strategy separates the two functions.
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
-
Method Summary
Modifier and TypeMethodDescriptionClass<? extends Constraint> gets the java class type of the constraint that this contraint processor handlesgetName()gets a descriptive name of this constraint processorbooleanreturns true if the processing of this constraint is something that can be opted out of by some pieces of code.process(DictionaryValidationResult result, T value, C constraint, AttributeValueReader attributeValueReader) process the provided constraint
-
Method Details
-
process
ProcessorResult process(DictionaryValidationResult result, T value, C constraint, AttributeValueReader attributeValueReader) throws AttributeValidationException process the provided constraint- Parameters:
result- - holds dictionary validation resultsvalue- - the value of the attributeconstraint- - the constraint to processattributeValueReader- - - provides access to the attribute being validated- Returns:
- the result of the constraint processing
- Throws:
AttributeValidationException
-
getName
String getName()gets a descriptive name of this constraint processore.g. @see CollectionSizeConstraintProcessor.CONSTRAINT_NAME
- Returns:
- a descriptive name
-
getConstraintType
Class<? extends Constraint> getConstraintType()gets the java class type of the constraint that this contraint processor handles- Returns:
- an instance of
Constraint
-
isOptional
boolean isOptional()returns true if the processing of this constraint is something that can be opted out of by some pieces of code. The only example of this in the version under development (1.1) is the existence constraint.- Returns:
- true if this processor can be turned off by some pieces of code, false otherwise
-