source: issuevalue/src/main/java/geniusweb/issuevalue/NumberValue.java@ 34

Last change on this file since 34 was 34, checked in by bart, 3 years ago

Added SAOP and simplerunner to GeniusWebPython. Several minor fixes.

File size: 1.2 KB
Line 
1package geniusweb.issuevalue;
2
3import java.math.BigDecimal;
4
5import com.fasterxml.jackson.annotation.JsonValue;
6
7/**
8 * A value containing a number, that should be in some {@link NumberValueSet}.
9 * immutable
10 */
11public class NumberValue implements Value {
12 @JsonValue // deserializes nicely but needs custom deserializer.
13 private final BigDecimal value;
14
15 public NumberValue(String vnew) {
16 this.value = new BigDecimal(vnew);
17 }
18
19 public NumberValue(BigDecimal vnew) {
20 this.value = vnew;
21 }
22
23 public BigDecimal getValue() {
24 return value;
25 }
26
27 @Override
28 public String toString() {
29 return value.toString();
30 }
31
32 @Override
33 public int hashCode() {
34 final int prime = 31;
35 int result = 1;
36 result = prime * result + ((value == null) ? 0 : value.hashCode());
37 return result;
38 }
39
40 @Override
41 public boolean equals(Object obj) {
42 if (this == obj)
43 return true;
44 if (obj == null)
45 return false;
46 if (getClass() != obj.getClass())
47 return false;
48 NumberValue other = (NumberValue) obj;
49 if (value == null) {
50 if (other.value != null)
51 return false;
52 } else if (value.compareTo(other.value) != 0)
53 // MANUAL FIX, DO NOT USE value.equals
54 return false;
55 return true;
56 }
57
58}
Note: See TracBrowser for help on using the repository browser.