KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > binding > method > Parameter


1 /*
2  * Copyright 2002-2006 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 package org.springframework.binding.method;
17
18 import java.io.Serializable JavaDoc;
19
20 import org.springframework.binding.expression.Expression;
21 import org.springframework.core.style.ToStringCreator;
22 import org.springframework.util.Assert;
23 import org.springframework.util.ObjectUtils;
24
25 /**
26  * A named method parameter. Each parameter has an identifying name and is of a
27  * specified type (class).
28  *
29  * @author Keith
30  */

31 public class Parameter implements Serializable JavaDoc {
32
33     /**
34      * The class of the parameter, e.g "springbank.AccountNumber".
35      */

36     private Class JavaDoc type;
37
38     /**
39      * The name of the parameter as an evaluatable expression, e.g
40      * "accountNumber".
41      */

42     private Expression name;
43
44     /**
45      * Create a new named parameter definition.
46      *
47      * @param type the type
48      * @param name the name
49      */

50     public Parameter(Class JavaDoc type, Expression name) {
51         Assert.notNull(name, "The parameter name expression is required");
52         this.type = type;
53         this.name = name;
54     }
55
56     public Class JavaDoc getType() {
57         return type;
58     }
59
60     public Expression getName() {
61         return name;
62     }
63
64     public boolean equals(Object JavaDoc obj) {
65         if (!(obj instanceof Parameter)) {
66             return false;
67         }
68         Parameter other = (Parameter)obj;
69         return ObjectUtils.nullSafeEquals(type, other.type) && name.equals(other.name);
70     }
71
72     public int hashCode() {
73         return (type != null ? type.hashCode() : 0) + name.hashCode();
74     }
75
76     public String JavaDoc toString() {
77         return new ToStringCreator(this).append("type", type).append("name", name).toString();
78     }
79 }
Popular Tags