01: package org.drools.facttemplates;
02:
03: import org.drools.base.ValueType;
04:
05: public class FieldTemplateImpl implements FieldTemplate {
06:
07: private static final long serialVersionUID = 400L;
08:
09: private final String name;
10: private final int index;
11: private final ValueType valueType;
12:
13: public FieldTemplateImpl(final String name, final int index,
14: final Class clazz) {
15: this .name = name;
16: this .index = index;
17: this .valueType = ValueType.determineValueType(clazz);
18: }
19:
20: /* (non-Javadoc)
21: * @see org.drools.facttemplates.FieldTemplate#getIndex()
22: */
23: public int getIndex() {
24: return this .index;
25: }
26:
27: /* (non-Javadoc)
28: * @see org.drools.facttemplates.FieldTemplate#getName()
29: */
30: public String getName() {
31: return this .name;
32: }
33:
34: /* (non-Javadoc)
35: * @see org.drools.facttemplates.FieldTemplate#getValueType()
36: */
37: public ValueType getValueType() {
38: return this .valueType;
39: }
40:
41: public int hashCode() {
42: final int PRIME = 31;
43: int result = 1;
44: result = PRIME * result + this .index;
45: result = PRIME * result + this .name.hashCode();
46: result = PRIME * result + this .valueType.hashCode();
47: return result;
48: }
49:
50: public boolean equals(final Object object) {
51: if (this == object) {
52: return true;
53: }
54:
55: if (object == null || getClass() != object.getClass()) {
56: return false;
57: }
58:
59: final FieldTemplateImpl other = (FieldTemplateImpl) object;
60:
61: return this.index == other.index
62: && this.name.equals(other.name)
63: && this.valueType.equals(other.valueType);
64: }
65:
66: }
|