Interface ConstraintProcessor<T,C extends Constraint>

Type Parameters:
T - constrainable data type
C - 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 Details

    • process

      ProcessorResult process(DictionaryValidationResult result, T value, C constraint, AttributeValueReader attributeValueReader) throws AttributeValidationException
      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
    • getName

      String getName()
      gets a descriptive name of this constraint processor

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