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