001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krad.datadictionary.validation.processor; 017 018 019import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException; 020import org.kuali.rice.krad.datadictionary.validation.AttributeValueReader; 021import org.kuali.rice.krad.datadictionary.validation.constraint.Constraint; 022import org.kuali.rice.krad.datadictionary.validation.result.DictionaryValidationResult; 023import org.kuali.rice.krad.datadictionary.validation.result.ProcessorResult; 024 025/** 026 * This interface must be implemented by constraint processors, which validate individual constraints in the 027 * data dictionary. The idea is that each constraint has its own processor, and that the validation service can be configured 028 * via dependency injection with a list of processors. This gives institutions the ability to easily modify how validation 029 * should be handled and to add arbitrary new constraints and constraint processors. An alternative might have been to put 030 * the process() method into the Constraint marker interface and have each Constraint define its own processing, but that would 031 * have forced business logic into what are naturally API classes (classes that implement Constraint). This strategy separates 032 * the two functions. 033 * 034 * @author Kuali Rice Team (rice.collab@kuali.org) 035 */ 036public interface ConstraintProcessor<T, C extends Constraint> { 037 038 public ProcessorResult process(DictionaryValidationResult result, T value, C constraint, AttributeValueReader attributeValueReader) throws AttributeValidationException; 039 040 public String getName(); 041 042 public Class<? extends Constraint> getConstraintType(); 043 044 /** 045 * This method return true if the processing of this constraint is something that can be opted out of by some pieces of code. 046 * The only example of this in the version under development (1.1) is the existence constraint. 047 * 048 * @return true if this processor can be turned off by some pieces of code, false otherwise 049 */ 050 public boolean isOptional(); 051 052}