@@ -49,41 +49,42 @@ public class LinkedCaseInsensitiveMap<V> implements Map<String, V>, Serializable
4949
5050
5151 /**
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)
5455 */
5556 public LinkedCaseInsensitiveMap () {
5657 this ((Locale ) null );
5758 }
5859
5960 /**
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 )
6465 */
6566 public LinkedCaseInsensitiveMap (@ Nullable Locale locale ) {
6667 this (16 , locale );
6768 }
6869
6970 /**
7071 * 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) .
7374 * @param initialCapacity the initial capacity
74- * @see java.lang.String#toLowerCase( )
75+ * @see #convertKey(String )
7576 */
7677 public LinkedCaseInsensitiveMap (int initialCapacity ) {
7778 this (initialCapacity , null );
7879 }
7980
8081 /**
8182 * 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) .
8485 * @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 )
8788 */
8889 public LinkedCaseInsensitiveMap (int initialCapacity , @ Nullable Locale locale ) {
8990 this .targetMap = new LinkedHashMap <String , V >(initialCapacity ) {
@@ -115,6 +116,8 @@ private LinkedCaseInsensitiveMap(LinkedCaseInsensitiveMap<V> other) {
115116 }
116117
117118
119+ // Implementation of java.util.Map
120+
118121 @ Override
119122 public int size () {
120123 return this .targetMap .size ();
@@ -159,7 +162,7 @@ public V getOrDefault(Object key, V defaultValue) {
159162 }
160163
161164 @ Override
162- public V put (String key , V value ) {
165+ public V put (String key , @ Nullable V value ) {
163166 String oldKey = this .caseInsensitiveKeys .put (convertKey (key ), key );
164167 if (oldKey != null && !oldKey .equals (key )) {
165168 this .targetMap .remove (oldKey );
@@ -229,16 +232,29 @@ public String toString() {
229232 }
230233
231234
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+
232248 /**
233249 * Convert the given key to a case-insensitive key.
234250 * <p>The default implementation converts the key
235251 * to lower-case according to this Map's Locale.
236252 * @param key the user-specified key
237253 * @return the key to use for storing
238- * @see java.lang. String#toLowerCase(java.util. Locale)
254+ * @see String#toLowerCase(Locale)
239255 */
240256 protected String convertKey (String key ) {
241- return key .toLowerCase (this . locale );
257+ return key .toLowerCase (getLocale () );
242258 }
243259
244260 /**
0 commit comments