View Javadoc

1   /*
2    * Copyright 2004-2009 the original author or authors.
3    *
4    * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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  
17  package org.springmodules.validation.util.condition.bean;
18  
19  import org.springframework.beans.BeanWrapper;
20  import org.springframework.beans.BeanWrapperImpl;
21  import org.springmodules.validation.util.condition.NonNullAcceptingCondition;
22  
23  /**
24   * A parent class to all bean related conditions. Such condition may perform checks on beans
25   * properties.
26   *
27   * @author Uri Boness
28   */
29  public abstract class AbstractBeanCondition extends NonNullAcceptingCondition {
30  
31      /**
32       * See {@link org.springmodules.validation.util.condition.Condition#check(Object)}. This method creates a
33       * {@link BeanWrapper} instance of the checked object and delegates the call to
34       * {@link #checkBean(org.springframework.beans.BeanWrapper)};
35       *
36       * @throws IllegalArgumentException when the passed in object is <code>null</code>.
37       */
38      public final boolean doCheck(Object object) {
39          return checkBean(new BeanWrapperImpl(object));
40      }
41  
42      protected abstract boolean checkBean(BeanWrapper beanWrapper);
43  
44  }