1 package uk.ac.ebi.intenz.domain.constants;
2
3
4
5
6
7
8
9
10
11
12 public class EventConstant {
13 private final String eventCode;
14
15 private final String eventFullName;
16
17 public static final EventConstant DELETION = new EventConstant("DEL", "deleted");
18 public static final EventConstant TRANSFER = new EventConstant("TRA", "transferred");
19 public static final EventConstant MODIFICATION = new EventConstant("MOD", "modified");
20 public static final EventConstant CREATION = new EventConstant("NEW", "created");
21
22
23
24
25
26
27
28 private EventConstant(String eventCode, String eventFullName) {
29 this.eventCode = eventCode;
30 this.eventFullName = eventFullName;
31 }
32
33
34
35
36
37
38
39
40
41
42 public static EventConstant valueOf(String eventCode) {
43 if (eventCode.equals(DELETION.getCode())) return DELETION;
44 if (eventCode.equals(TRANSFER.getCode())) return TRANSFER;
45 if (eventCode.equals(MODIFICATION.getCode())) return MODIFICATION;
46 if (eventCode.equals(CREATION.getCode())) return CREATION;
47 throw new IllegalArgumentException();
48 }
49
50
51
52
53
54
55
56 public boolean equals(Object o) {
57 if (this == o) return true;
58 if (!(o instanceof EventConstant)) return false;
59
60 final EventConstant eventConstants = (EventConstant) o;
61
62 if (eventCode != null ? !eventCode.equals(eventConstants.eventCode) : eventConstants.eventCode != null) return false;
63 if (eventFullName != null ? !eventFullName.equals(eventConstants.eventFullName) : eventConstants.eventFullName != null) return false;
64
65 return true;
66 }
67
68
69
70
71
72
73 public int hashCode() {
74 int result;
75 result = (eventCode != null ? eventCode.hashCode() : 0);
76 result = 29 * result + (eventFullName != null ? eventFullName.hashCode() : 0);
77 return result;
78 }
79
80
81
82
83
84
85 public String toString() {
86 return eventFullName;
87 }
88
89
90
91
92
93
94
95
96
97 public String getCode() {
98 return eventCode;
99 }
100 }