View Javadoc

1   package com.silvermindsoftware.hitch.reflect;
2   
3   import java.lang.reflect.Field;
4   
5   /**
6    * Copyright 2007 Brandon Goodin
7    *
8    * Licensed under the Apache License, Version 2.0 (the "License");
9    * you may not use this file except in compliance with the License.
10   * You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  
21  /**
22   * @svnLink $Revision: 3875 $;$Date: 2009-08-04 14:35:53 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/swing/src/main/java/com/silvermindsoftware/hitch/reflect/FieldInfo.java $
23   */
24  public class FieldInfo {
25  
26  	private Field field;
27  
28  	private Class type;
29  	private String name;
30  
31  
32  	public FieldInfo(Field field) {
33  		this.field = field;
34  		this.name = field.getName();
35  		this.type = field.getType();
36  	}
37  
38  	public Field getField() {
39  		return field;
40  	}
41  
42  	public boolean equals(Object o) {
43  		if (this == o) return true;
44  		if (o == null || getClass() != o.getClass()) return false;
45  
46  		FieldInfo fieldInfo = (FieldInfo) o;
47  
48  		if (!name.equals(fieldInfo.name)) return false;
49  		if (!type.equals(fieldInfo.type)) return false;
50  
51  		return true;
52  	}
53  
54  	public int hashCode() {
55  		int result;
56  		result = type.hashCode();
57  		result = 31 * result + name.hashCode();
58  		return result;
59  	}
60  
61  	public String toString() {
62  		return new StringBuilder().append(type.getName()).append(" ").append(name).toString();
63  	}
64  }