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

Last change on this file since 27 was 27, checked in by bart, 4 years ago
  • party capabilities now include profile information. Existing parties may need small fix * plot layout shows accepts * VotingEvaluator use group power instead of group size * runsession you can now also select MOPAC-only parties
File size: 1.1 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.equals(other.value))
53 return false;
54 return true;
55 }
56
57}
Note: See TracBrowser for help on using the repository browser.