1 /**
2 * Copyright 2005-2012 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.krad.datadictionary.validation.constraint.provider;
17
18 import org.kuali.rice.krad.datadictionary.validation.capability.Constrainable;
19 import org.kuali.rice.krad.datadictionary.validation.constraint.Constraint;
20
21 import java.util.List;
22
23 /**
24 * ConstraintProvider determines a list of constraints for a given Constrainable definition for an attribute
25 * in the data dictionary
26 *
27 * <p>The ConstraintProvider interface must be implemented by any class that contributes
28 * Constraints to the DictionaryValidationService. Multiple ConstraintProviders can be registered simultaneously,
29 * and each can contribute constraints for any number of constraint types.</p>
30 *
31 * <p>
32 * These constraints can be looked up in a variety of ways. They may be:
33 * <ol>
34 * <li> member variables of the Constrainable definition itself {@see CaseConstrainable.class}</li>
35 * <li> the Constrainable definition itself may extend Constraint {@see LengthConstrainable.class}</li>
36 * <li> provided from some external source, or generated on the fly</li>
37 * </ol>
38 * </p>
39 * <p>The goal here is to provide a mechanism that enables implementing institutions to inject new Constraints and ConstraintProcessor
40 * classes into the DictionaryValidationService implementation via dependency injection.</p>
41 *
42 * @author Kuali Rice Team (rice.collab@kuali.org)
43 * @since 1.1
44 */
45 public interface ConstraintProvider<T extends Constrainable> {
46
47 /**
48 * gets the constraints provided
49 *
50 * @param definition - a Data Dictionary definition e.g. {@code ComplexAttributeDefinition} or {@code CollectionDefinition}
51 * @param constraintType - a java class that represents the constraint
52 * @return the list of constraints
53 */
54 public List<Constraint> getConstraints(T definition, Class<? extends Constraint> constraintType);
55
56 /**
57 * checks whether this provider supports the provided definition
58 *
59 * @param definition - a Data Dictionary definition e.g. {@code AttributeDefinition}
60 * @return true if supported, false otherwise
61 */
62 public boolean isSupported(Constrainable definition);
63
64 }