@@ -70,8 +70,14 @@ public class Languages {
70
70
*/
71
71
public abstract static class LanguageSet {
72
72
73
- public static LanguageSet from (final Set <String > langs ) {
74
- return langs .isEmpty () ? NO_LANGUAGES : new SomeLanguages (langs );
73
+ /**
74
+ * Gets a language set for the given languages.
75
+ *
76
+ * @param languages a language set.
77
+ * @return a LanguageSet.
78
+ */
79
+ public static LanguageSet from (final Set <String > languages ) {
80
+ return languages .isEmpty () ? NO_LANGUAGES : new SomeLanguages (languages );
75
81
}
76
82
77
83
/**
@@ -81,16 +87,43 @@ public LanguageSet() {
81
87
// empty
82
88
}
83
89
90
+ /**
91
+ * Tests whether this instance contains the given value.
92
+ *
93
+ * @param language the value to test.
94
+ * @return whether this instance contains the given value.
95
+ */
84
96
public abstract boolean contains (String language );
85
97
98
+ /**
99
+ * Gets any of this instance's element.
100
+ *
101
+ * @return any of this instance's element.
102
+ */
86
103
public abstract String getAny ();
87
104
105
+ /**
106
+ * Tests whether this instance is empty.
107
+ *
108
+ * @return whether this instance is empty.
109
+ */
88
110
public abstract boolean isEmpty ();
89
111
112
+ /**
113
+ * Tests whether this instance contains a single element.
114
+ *
115
+ * @return whether this instance contains a single element.
116
+ */
90
117
public abstract boolean isSingleton ();
91
118
92
119
abstract LanguageSet merge (LanguageSet other );
93
120
121
+ /**
122
+ * Returns an instance restricted to this instances and the given values'.
123
+ *
124
+ * @param other The other instance.
125
+ * @return an instance restricted to this instances and the given values'.
126
+ */
94
127
public abstract LanguageSet restrictTo (LanguageSet other );
95
128
}
96
129
@@ -114,6 +147,11 @@ public String getAny() {
114
147
return this .languages .iterator ().next ();
115
148
}
116
149
150
+ /**
151
+ * Gets the language strings
152
+ *
153
+ * @return the languages strings.
154
+ */
117
155
public Set <String > getLanguages () {
118
156
return this .languages ;
119
157
}
@@ -161,6 +199,9 @@ public String toString() {
161
199
162
200
}
163
201
202
+ /**
203
+ * Marker for any language.
204
+ */
164
205
public static final String ANY = "any" ;
165
206
166
207
private static final Map <NameType , Languages > LANGUAGES = new EnumMap <>(NameType .class );
@@ -253,10 +294,22 @@ public String toString() {
253
294
}
254
295
}
255
296
297
+ /**
298
+ * Gets an instance for the given name type.
299
+ *
300
+ * @param nameType The name type to lookup.
301
+ * @return an instance for the given name type.
302
+ */
256
303
public static Languages getInstance (final NameType nameType ) {
257
304
return LANGUAGES .get (nameType );
258
305
}
259
306
307
+ /**
308
+ * Gets a new instance for the given resource name.
309
+ *
310
+ * @param languagesResourceName the resource name to lookup.
311
+ * @return a new instance.
312
+ */
260
313
public static Languages getInstance (final String languagesResourceName ) {
261
314
// read languages list
262
315
final Set <String > ls = new HashSet <>();
@@ -289,6 +342,11 @@ private Languages(final Set<String> languages) {
289
342
this .languages = languages ;
290
343
}
291
344
345
+ /**
346
+ * Gets the language set.
347
+ *
348
+ * @return the language set.
349
+ */
292
350
public Set <String > getLanguages () {
293
351
return this .languages ;
294
352
}
0 commit comments