Last change
on this file since 741 was 526, checked in by wouter, 17 months ago |
small fixes in java to fit translation requirements
|
File size:
1.1 KB
|
Line | |
---|
1 | package geniusweb.issuevalue;
|
---|
2 |
|
---|
3 | import com.fasterxml.jackson.annotation.JsonValue;
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * A value for a discrete issue. Constructor guarantees this is non-null and
|
---|
7 | * non-empty. immutable.
|
---|
8 | */
|
---|
9 | public class DiscreteValue implements Value {
|
---|
10 |
|
---|
11 | // serializes nicely but requires custom deserializer.
|
---|
12 | private final String value;
|
---|
13 |
|
---|
14 | public DiscreteValue(String value) {
|
---|
15 | if (value == null || value.isEmpty())
|
---|
16 | throw new NullPointerException(
|
---|
17 | "value must be non-null and non-empty");
|
---|
18 | this.value = value;
|
---|
19 | }
|
---|
20 |
|
---|
21 | @Override
|
---|
22 | public int hashCode() {
|
---|
23 | final int prime = 31;
|
---|
24 | int result = 1;
|
---|
25 | result = prime * result + ((value == null) ? 0 : value.hashCode());
|
---|
26 | return result;
|
---|
27 | }
|
---|
28 |
|
---|
29 | @Override
|
---|
30 | public boolean equals(Object obj) {
|
---|
31 | if (this == obj)
|
---|
32 | return true;
|
---|
33 | if (obj == null)
|
---|
34 | return false;
|
---|
35 | if (getClass() != obj.getClass())
|
---|
36 | return false;
|
---|
37 | DiscreteValue other = (DiscreteValue) obj;
|
---|
38 | if (value == null) {
|
---|
39 | if (other.value != null)
|
---|
40 | return false;
|
---|
41 | } else if (!value.equals(other.value))
|
---|
42 | return false;
|
---|
43 | return true;
|
---|
44 | }
|
---|
45 |
|
---|
46 | @Override
|
---|
47 | public String toString() {
|
---|
48 | return "\"" + value + "\"";
|
---|
49 | }
|
---|
50 |
|
---|
51 | @JsonValue
|
---|
52 | public String getValue() {
|
---|
53 | return value;
|
---|
54 | }
|
---|
55 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.