View Javadoc
1   /**
2    * Copyright 2005-2016 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 java.util.List;
19  
20  import org.kuali.rice.krad.datadictionary.validation.capability.CaseConstrainable;
21  import org.kuali.rice.krad.datadictionary.validation.capability.Constrainable;
22  import org.kuali.rice.krad.datadictionary.validation.capability.LengthConstrainable;
23  import org.kuali.rice.krad.datadictionary.validation.constraint.Constraint;
24  
25  /**
26   * ConstraintProvider determines a list of constraints for a given Constrainable definition for an attribute
27   * in the data dictionary
28   *
29   * <p>The ConstraintProvider interface must be implemented by any class that contributes
30   * Constraints to the DictionaryValidationService. Multiple ConstraintProviders can be registered simultaneously,
31   * and each can contribute constraints for any number of constraint types.</p>
32   *
33   * <p>
34   * These constraints can be looked up in a variety of ways. They may be:
35   * <ol>
36   * <li> member variables of the Constrainable definition itself {@link CaseConstrainable}</li>
37   * <li> the Constrainable definition itself may extend Constraint {@link LengthConstrainable}</li>
38   * <li> provided from some external source, or generated on the fly</li>
39   * </ol>
40   * </p>
41   * <p>The goal here is to provide a mechanism that enables implementing institutions to inject new Constraints and
42   * ConstraintProcessor
43   * classes into the DictionaryValidationService implementation via dependency injection.</p>
44   *
45   * @author Kuali Rice Team (rice.collab@kuali.org)
46   * @param <T> constrainable type
47   * @since 1.1
48   */
49  public interface ConstraintProvider<T extends Constrainable> {
50  
51      /**
52       * gets the constraints provided
53       *
54       * @param definition - a Data Dictionary definition e.g. {@code ComplexAttributeDefinition} or {@code
55       * CollectionDefinition}
56       * @param constraintType - a java class that represents the constraint
57       * @return the list of constraints
58       */
59      public List<Constraint> getConstraints(T definition, Class<? extends Constraint> constraintType);
60  
61      /**
62       * checks whether this provider supports the provided definition
63       *
64       * @param definition - a Data Dictionary definition e.g. {@code AttributeDefinition}
65       * @return true if supported, false otherwise
66       */
67      public boolean isSupported(Constrainable definition);
68  
69  }