View Javadoc

1   /**
2    * Copyright 2005-2014 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
40   * ConstraintProcessor
41   * classes into the DictionaryValidationService implementation via dependency injection.</p>
42   *
43   * @author Kuali Rice Team (rice.collab@kuali.org)
44   * @since 1.1
45   */
46  public interface ConstraintProvider<T extends Constrainable> {
47  
48      /**
49       * gets the constraints provided
50       *
51       * @param definition - a Data Dictionary definition e.g. {@code ComplexAttributeDefinition} or {@code
52       * CollectionDefinition}
53       * @param constraintType - a java class that represents the constraint
54       * @return the list of constraints
55       */
56      public List<Constraint> getConstraints(T definition, Class<? extends Constraint> constraintType);
57  
58      /**
59       * checks whether this provider supports the provided definition
60       *
61       * @param definition - a Data Dictionary definition e.g. {@code AttributeDefinition}
62       * @return true if supported, false otherwise
63       */
64      public boolean isSupported(Constrainable definition);
65  
66  }