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