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.bean.rule.resolver;
18  
19  /**
20   * An {@link org.springmodules.validation.bean.rule.resolver.ErrorArgumentsResolver} that is statically pre-configured with the error arguments, that is, the
21   * arguments are not dependent on the validated object.
22   *
23   * @author Uri Boness
24   */
25  public class StaticErrorArgumentsResolver implements ErrorArgumentsResolver {
26  
27      private Object[] arguments;
28  
29      /**
30       * Constructs a new StaticErrorArgumentsResolver with no arguments.
31       */
32      public StaticErrorArgumentsResolver() {
33          this(new Object[0]);
34      }
35  
36      /**
37       * Constructs a new StaticErrorArgumentsResolver with given static arguments.
38       *
39       * @param arguments The given static arguments.
40       */
41      public StaticErrorArgumentsResolver(Object[] arguments) {
42          this.arguments = arguments;
43      }
44  
45      /**
46       * Returns the arguments that are configured in this resolver.
47       *
48       * @see ErrorArgumentsResolver#resolveArguments(Object)
49       */
50      public Object[] resolveArguments(Object obj) {
51          return arguments;
52      }
53  
54      //=============================================== Setter/Getter ====================================================
55  
56      /**
57       * Sets the static arguments to be returned by this resolver.
58       *
59       * @param arguments The static arguments to be returned by this resolver.
60       */
61      public void setArguments(Object[] arguments) {
62          this.arguments = arguments;
63      }
64  }