01: package org.drools.base.field;
02:
03: import org.drools.RuntimeDroolsException;
04: import org.drools.spi.FieldValue;
05:
06: public class LongFieldImpl implements FieldValue {
07:
08: private static final long serialVersionUID = 400L;
09: private final long value;
10:
11: public LongFieldImpl(final long value) {
12: this .value = value;
13: }
14:
15: public Object getValue() {
16: return new Long(this .value);
17: }
18:
19: public String toString() {
20: return String.valueOf(this .value);
21: }
22:
23: public boolean getBooleanValue() {
24: throw new RuntimeDroolsException(
25: "Conversion to boolean not supported for type long");
26: }
27:
28: public byte getByteValue() {
29: return (byte) this .value;
30: }
31:
32: public char getCharValue() {
33: return (char) this .value;
34: }
35:
36: public double getDoubleValue() {
37: return this .value;
38: }
39:
40: public float getFloatValue() {
41: return this .value;
42: }
43:
44: public int getIntValue() {
45: return (int) this .value;
46: }
47:
48: public long getLongValue() {
49: return this .value;
50: }
51:
52: public short getShortValue() {
53: return (short) this .value;
54: }
55:
56: public boolean equals(final Object object) {
57: if (this == object) {
58: return true;
59: }
60: if (object == null || !(object instanceof LongFieldImpl)) {
61: return false;
62: }
63: final LongFieldImpl other = (LongFieldImpl) object;
64:
65: return this .value == other.value;
66: }
67:
68: public int hashCode() {
69: return (int) this .value;
70: }
71:
72: public boolean isNull() {
73: return false;
74: }
75:
76: public boolean isBooleanField() {
77: return false;
78: }
79:
80: public boolean isFloatNumberField() {
81: return false;
82: }
83:
84: public boolean isIntegerNumberField() {
85: return true;
86: }
87:
88: public boolean isObjectField() {
89: return false;
90: }
91:
92: public boolean isCollectionField() {
93: return false;
94: }
95:
96: }
|