01: package com.silvermindsoftware.hitch.reflect;
02:
03: import java.lang.reflect.Field;
04:
05: /**
06: * Copyright 2007 Brandon Goodin
07: *
08: * Licensed under the Apache License, Version 2.0 (the "License");
09: * 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: public class FieldInfo {
22:
23: private Field field;
24:
25: private Class type;
26: private String name;
27:
28: public FieldInfo(Field field) {
29: this .field = field;
30: this .name = field.getName();
31: this .type = field.getType();
32: }
33:
34: public Field getField() {
35: return field;
36: }
37:
38: public boolean equals(Object o) {
39: if (this == o)
40: return true;
41: if (o == null || getClass() != o.getClass())
42: return false;
43:
44: FieldInfo fieldInfo = (FieldInfo) o;
45:
46: if (!name.equals(fieldInfo.name))
47: return false;
48: if (!type.equals(fieldInfo.type))
49: 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(" ")
63: .append(name).toString();
64: }
65: }
|