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.io.Serializable;
25 import java.util.Comparator;
26
27
28
29
30
31
32
33 public class CustomFieldValue extends AbstractEntity {
34
35
36
37
38 private static final long serialVersionUID = 1L;
39 public static final Comparator<CustomFieldValue> SORT_ORDER_COMPARATOR = new SortOrderComparator();
40
41
42
43
44 private CustomField customField;
45
46
47
48
49
50 private String value;
51
52
53
54
55
56 private int sortOrder;
57
58
59
60
61
62
63
64
65
66
67 public CustomFieldValue() {
68 }
69
70 public CustomFieldValue(CustomField customField, String value) {
71 setCustomField(customField);
72 setValue(value);
73 }
74
75 public CustomField getCustomField() {
76 return (customField);
77 }
78
79 public void setCustomField(CustomField customField) {
80 if (customField == null) {
81 throw new IllegalArgumentException("null customField");
82 }
83 this.customField = customField;
84 }
85
86
87 public String getValue() {
88 return value;
89 }
90
91
92
93
94 public void setValue(String value) {
95 if (value == null) {
96 throw new IllegalArgumentException("null value");
97 }
98 this.value = value;
99 }
100
101 public int getSortOrder() {
102 return sortOrder;
103 }
104
105 public void setSortOrder(int sortOrder) {
106 this.sortOrder = sortOrder;
107 }
108
109
110
111
112 @Override
113 public String toString() {
114 return new ToStringBuilder(this).append("id", getId()).append(
115 "customField", getCustomField()).append("value", getValue())
116 .toString();
117 }
118
119
120
121
122
123
124
125
126
127
128
129 private static class SortOrderComparator implements
130 Comparator<CustomFieldValue>, Serializable {
131
132
133
134 private static final long serialVersionUID = 1L;
135
136 public int compare(CustomFieldValue../../org/itracker/model/CustomFieldValue.html#CustomFieldValue">CustomFieldValue a, CustomFieldValue b) {
137 return new CompareToBuilder().append(a.getSortOrder(),
138 b.getSortOrder())
139 .toComparison();
140 }
141
142 }
143
144
145 }