View Javadoc

    1   /* Copyright 2004, 2005 Acegi Technology Pty Limited
    2    *
    3    * Licensed under the Apache License, Version 2.0 (the "License");
    4    * you may not use this file except in compliance with the License.
    5    * You may obtain a copy of the License at
    6    *
    7    *     http://www.apache.org/licenses/LICENSE-2.0
    8    *
    9    * Unless required by applicable law or agreed to in writing, software
    10   * distributed under the License is distributed on an "AS IS" BASIS,
    11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12   * See the License for the specific language governing permissions and
    13   * limitations under the License.
    14   */
    15
    16  package org.acegisecurity.domain.validation;
    17
    18  import org.springframework.util.Assert;
    19
    20  import org.springframework.validation.BindException;
    21
    22
    23  /***
    24   * Convenience class that invokes the {@link BindBeforeValidation} interface if
    25   * the passed domain object has requested it.
    26   *
    27   * @author Ben Alex
    28   * @version $Id: BindBeforeValidationUtils.java,v 1.2 2005/11/17 00:55:50 benalex Exp $
    29   */
    30  public class BindBeforeValidationUtils {
    31      //~ Methods ================================================================
    32
    33      /***
    34       * Call {@link BindBeforeValidation#bindSupport()} if the domain object
    35       * requests it.
    36       *
    37       * @param domainObject to attempt to bind (never <code>null</code>)
    38       *
    39       * @throws BindException if the binding failed
    40       */
    41      public static void bindIfRequired(Object domainObject)
    42          throws BindException {
    43          Assert.notNull(domainObject);
    44
    45          if (BindBeforeValidation.class.isAssignableFrom(domainObject.getClass())) {
    46              BindBeforeValidation bbv = (BindBeforeValidation) domainObject;
    47              bbv.bindSupport();
    48          }
    49      }
    50  }