01: package fit.decorator.util;
02:
03: import fit.decorator.exceptions.InvalidInputException;
04:
05: public class Delta {
06: private DataType dataType;
07: private Object value;
08:
09: public Delta(String dataType, String value)
10: throws InvalidInputException {
11: this .dataType = DataType.instance(dataType);
12: this .value = this .dataType.parse(value);
13: }
14:
15: public String addTo(String originalValue, int numberofTime) {
16: return dataType.addTo(originalValue, value, numberofTime);
17: }
18:
19: public boolean equals(Object other) {
20: if (this == other) {
21: return true;
22: }
23: if (null == other) {
24: return false;
25: }
26: if (!this .getClass().getName().equals(
27: other.getClass().getName())) {
28: return false;
29: }
30: return this .dataType.equals(((Delta) other).dataType)
31: && this .value.equals(((Delta) other).value);
32: }
33:
34: public String toString() {
35: return dataType.toString() + " and value = " + value;
36: }
37: }
|