001 /*
002 * Copyright 2002-2004 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005 * use this file except in compliance with the License. You may obtain a copy of
006 * the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
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, WITHOUT
012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013 * License for the specific language governing permissions and limitations under
014 * the License.
015 */
016 package org.springframework.rules;
017
018 import org.springframework.rules.constraint.property.PropertyConstraint;
019
020 /**
021 * Rules sources provide a mechanism for accessing rules associated with a bean
022 * class and specific bean properties. A rules source is effectively a "Rules"
023 * data access object.
024 *
025 * @author Keith Donald
026 * @TODO move to validation package at some point...
027 */
028 public interface RulesSource {
029
030 /**
031 * Return the validation rules for the provided bean.
032 *
033 * @param bean
034 * the bean class
035 * @return The validation rules, or <code>null</code> if none exist.
036 */
037 public Rules getRules(Class bean);
038
039 public Rules getRules(Class bean, String contextId);
040
041 /**
042 * Return the validation rules for the provided bean property.
043 *
044 * @param beanClass
045 * the bean class
046 * @param propertyName
047 * the bean propertyName
048 * @return The validation rules, or <code>null</code> if none exist.
049 */
050 public PropertyConstraint getPropertyConstraint(Class beanClass, String propertyName);
051
052 public PropertyConstraint getPropertyConstraint(Class beanClass, String propertyName, String contextId);
053
054 }