1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.itracker.model;
20
21 import org.apache.commons.lang.builder.CompareToBuilder;
22 import org.apache.commons.lang.builder.ToStringBuilder;
23
24 import java.util.ArrayList;
25 import java.util.Comparator;
26 import java.util.List;
27
28
29
30
31 public class SystemConfiguration extends AbstractEntity {
32
33
34 public static final Comparator<SystemConfiguration> VERSION_COMPARATOR = new SystemConfigurationComparator();
35
36
37
38 private static final long serialVersionUID = 1L;
39
40 private String version;
41
42 private List<CustomField> customFields = new ArrayList<CustomField>();
43
44 private List<Configuration> resolutions = new ArrayList<Configuration>();
45 private List<Configuration> severities = new ArrayList<Configuration>();
46 private List<Configuration> statuses = new ArrayList<Configuration>();
47
48 public SystemConfiguration() {
49 }
50
51 public String getVersion() {
52 return (version == null ? "" : version);
53 }
54
55 public void setVersion(String value) {
56 version = value;
57 }
58
59 public List<CustomField> getCustomFields() {
60 return customFields;
61 }
62
63 public void setCustomFields(List<CustomField> value) {
64 if (value != null) {
65 customFields = value;
66 }
67 }
68
69 public List<Configuration> getResolutions() {
70 return (resolutions == null ? new ArrayList<Configuration>()
71 : resolutions);
72 }
73
74 public void setResolutions(List<Configuration> value) {
75 if (value != null) {
76 resolutions = value;
77 }
78 }
79
80 public List<Configuration> getSeverities() {
81 return (severities == null ? new ArrayList<Configuration>()
82 : severities);
83 }
84
85 public void setSeverities(List<Configuration> value) {
86 if (value != null) {
87 severities = value;
88 }
89 }
90
91 public List<Configuration> getStatuses() {
92 return (statuses == null ? new ArrayList<Configuration>() : statuses);
93 }
94
95 public void setStatuses(List<Configuration> value) {
96 if (value != null) {
97 statuses = value;
98 }
99 }
100
101 public void addConfiguration(Configuration configuration) {
102 if (configuration != null) {
103 switch (configuration.getType()) {
104 case resolution:
105 resolutions.add(configuration);
106 break;
107 case severity:
108 severities.add(configuration);
109 break;
110 case status:
111 statuses.add(configuration);
112 break;
113 default:
114 return;
115 }
116 }
117 }
118
119 public String toString() {
120
121 return new ToStringBuilder(this).append("id", getId()).append("version", getVersion()).toString();
122
123 }
124
125 private static final class SystemConfigurationComparator implements
126 Comparator<SystemConfiguration> {
127 public int compare(SystemConfiguration./org/itracker/model/SystemConfiguration.html#SystemConfiguration">SystemConfiguration o1, SystemConfiguration o2) {
128 return new CompareToBuilder().append(o1.getVersion(),
129 o2.getVersion()).append(o1.getId(), o2.getId())
130 .toComparison();
131 }
132 }
133 }