1   package org.sourceforge.jemm.database;
2   
3   import java.io.Serializable;
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  public class FieldInfo implements Serializable {
26  	
27  	private static final long serialVersionUID = 1L;
28  
29  	
30  	public final String fieldName;
31  	
32  	public final FieldType fieldType;
33  	
34  	public final String className;
35  
36  	
37  
38  
39  
40  
41  
42  	public FieldInfo(String fieldName, String className, FieldType fieldType) {
43  		if (fieldName == null || fieldType == null || className == null)
44  			throw new IllegalArgumentException(
45  					"fieldName and fieldType must both be set");
46  
47  		this.fieldName = fieldName;
48  		this.className = className;
49  		this.fieldType = fieldType;
50  	}
51  
52  	
53  
54  
55  
56  
57  
58  	public FieldInfo(String fieldName, Class<?> classType, FieldType fieldType) {
59  		this(fieldName, classType.getName(), fieldType);
60  	}
61  
62  	@Override
63  	public int hashCode() {
64  		final int prime = 31;
65  		int result = 1;
66  		result = prime * result + fieldName.hashCode();
67  		result = prime * result + fieldType.hashCode();
68  		result = prime * result + className.hashCode();
69  		return result;
70  	}
71  
72  	@Override
73  	public boolean equals(Object obj) {
74  		if (this == obj)
75  			return true;
76  		if (obj == null)
77  			return false;
78  		if (getClass() != obj.getClass())
79  			return false;
80  		FieldInfo other = (FieldInfo) obj;
81  
82  		return fieldName.equals(other.fieldName)
83  				&& fieldType.equals(other.fieldType)
84  				&& className.equals(other.className);
85  	}
86  
87  	@Override
88  	public String toString() {
89  		StringBuilder sb = new StringBuilder("FieldInfo(");
90  		sb.append(fieldName).append(",");
91  		sb.append(className).append(",");
92  		sb.append(fieldType).append(')');
93  
94  		return sb.toString();
95  	}
96  }