@@ -49,41 +49,42 @@ public class LinkedCaseInsensitiveMap<V> implements Map<String, V>, Serializable
49
49
50
50
51
51
/**
52
- * Create a new LinkedCaseInsensitiveMap for the default Locale.
53
- * @see java.lang.String#toLowerCase()
52
+ * Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys
53
+ * according to the default Locale (by default in lower case).
54
+ * @see #convertKey(String)
54
55
*/
55
56
public LinkedCaseInsensitiveMap () {
56
57
this ((Locale ) null );
57
58
}
58
59
59
60
/**
60
- * Create a new LinkedCaseInsensitiveMap that stores lower- case keys
61
- * according to the given Locale.
62
- * @param locale the Locale to use for lower- case conversion
63
- * @see java.lang.String#toLowerCase(java.util.Locale )
61
+ * Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys
62
+ * according to the given Locale (by default in lower case) .
63
+ * @param locale the Locale to use for case-insensitive key conversion
64
+ * @see #convertKey(String )
64
65
*/
65
66
public LinkedCaseInsensitiveMap (@ Nullable Locale locale ) {
66
67
this (16 , locale );
67
68
}
68
69
69
70
/**
70
71
* Create a new LinkedCaseInsensitiveMap that wraps a {@link LinkedHashMap}
71
- * with the given initial capacity and stores lower- case keys according
72
- * to the default Locale.
72
+ * with the given initial capacity and stores case-insensitive keys
73
+ * according to the default Locale (by default in lower case) .
73
74
* @param initialCapacity the initial capacity
74
- * @see java.lang.String#toLowerCase( )
75
+ * @see #convertKey(String )
75
76
*/
76
77
public LinkedCaseInsensitiveMap (int initialCapacity ) {
77
78
this (initialCapacity , null );
78
79
}
79
80
80
81
/**
81
82
* Create a new LinkedCaseInsensitiveMap that wraps a {@link LinkedHashMap}
82
- * with the given initial capacity and stores lower- case keys according
83
- * to the given Locale.
83
+ * with the given initial capacity and stores case-insensitive keys
84
+ * according to the given Locale (by default in lower case) .
84
85
* @param initialCapacity the initial capacity
85
- * @param locale the Locale to use for lower- case conversion
86
- * @see java.lang.String#toLowerCase(java.util.Locale )
86
+ * @param locale the Locale to use for case-insensitive key conversion
87
+ * @see #convertKey(String )
87
88
*/
88
89
public LinkedCaseInsensitiveMap (int initialCapacity , @ Nullable Locale locale ) {
89
90
this .targetMap = new LinkedHashMap <String , V >(initialCapacity ) {
@@ -115,6 +116,8 @@ private LinkedCaseInsensitiveMap(LinkedCaseInsensitiveMap<V> other) {
115
116
}
116
117
117
118
119
+ // Implementation of java.util.Map
120
+
118
121
@ Override
119
122
public int size () {
120
123
return this .targetMap .size ();
@@ -159,7 +162,7 @@ public V getOrDefault(Object key, V defaultValue) {
159
162
}
160
163
161
164
@ Override
162
- public V put (String key , V value ) {
165
+ public V put (String key , @ Nullable V value ) {
163
166
String oldKey = this .caseInsensitiveKeys .put (convertKey (key ), key );
164
167
if (oldKey != null && !oldKey .equals (key )) {
165
168
this .targetMap .remove (oldKey );
@@ -229,16 +232,29 @@ public String toString() {
229
232
}
230
233
231
234
235
+ // Specific to LinkedCaseInsensitiveMap
236
+
237
+ /**
238
+ * Return the locale used by this {@code LinkedCaseInsensitiveMap}.
239
+ * Used for case-insensitive key conversion.
240
+ * @since 4.3.10
241
+ * @see #LinkedCaseInsensitiveMap(Locale)
242
+ * @see #convertKey(String)
243
+ */
244
+ public Locale getLocale () {
245
+ return this .locale ;
246
+ }
247
+
232
248
/**
233
249
* Convert the given key to a case-insensitive key.
234
250
* <p>The default implementation converts the key
235
251
* to lower-case according to this Map's Locale.
236
252
* @param key the user-specified key
237
253
* @return the key to use for storing
238
- * @see java.lang. String#toLowerCase(java.util. Locale)
254
+ * @see String#toLowerCase(Locale)
239
255
*/
240
256
protected String convertKey (String key ) {
241
- return key .toLowerCase (this . locale );
257
+ return key .toLowerCase (getLocale () );
242
258
}
243
259
244
260
/**
0 commit comments