001/** 002 * Copyright 2005-2018 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.constraint.provider; 017 018import java.util.List; 019 020import org.kuali.rice.krad.datadictionary.validation.capability.CaseConstrainable; 021import org.kuali.rice.krad.datadictionary.validation.capability.Constrainable; 022import org.kuali.rice.krad.datadictionary.validation.capability.LengthConstrainable; 023import org.kuali.rice.krad.datadictionary.validation.constraint.Constraint; 024 025/** 026 * ConstraintProvider determines a list of constraints for a given Constrainable definition for an attribute 027 * in the data dictionary 028 * 029 * <p>The ConstraintProvider interface must be implemented by any class that contributes 030 * Constraints to the DictionaryValidationService. Multiple ConstraintProviders can be registered simultaneously, 031 * and each can contribute constraints for any number of constraint types.</p> 032 * 033 * <p> 034 * These constraints can be looked up in a variety of ways. They may be: 035 * <ol> 036 * <li> member variables of the Constrainable definition itself {@link CaseConstrainable}</li> 037 * <li> the Constrainable definition itself may extend Constraint {@link LengthConstrainable}</li> 038 * <li> provided from some external source, or generated on the fly</li> 039 * </ol> 040 * </p> 041 * <p>The goal here is to provide a mechanism that enables implementing institutions to inject new Constraints and 042 * ConstraintProcessor 043 * classes into the DictionaryValidationService implementation via dependency injection.</p> 044 * 045 * @author Kuali Rice Team (rice.collab@kuali.org) 046 * @param <T> constrainable type 047 * @since 1.1 048 */ 049public interface ConstraintProvider<T extends Constrainable> { 050 051 /** 052 * gets the constraints provided 053 * 054 * @param definition - a Data Dictionary definition e.g. {@code ComplexAttributeDefinition} or {@code 055 * CollectionDefinition} 056 * @param constraintType - a java class that represents the constraint 057 * @return the list of constraints 058 */ 059 public List<Constraint> getConstraints(T definition, Class<? extends Constraint> constraintType); 060 061 /** 062 * checks whether this provider supports the provided definition 063 * 064 * @param definition - a Data Dictionary definition e.g. {@code AttributeDefinition} 065 * @return true if supported, false otherwise 066 */ 067 public boolean isSupported(Constrainable definition); 068 069}