11/*
2- * Copyright 2002-2016 the original author or authors.
2+ * Copyright 2002-2017 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -85,6 +85,10 @@ public LinkedCaseInsensitiveMap(int initialCapacity) {
8585 */
8686 public LinkedCaseInsensitiveMap (int initialCapacity , Locale locale ) {
8787 this .targetMap = new LinkedHashMap <String , V >(initialCapacity ) {
88+ @ Override
89+ public boolean containsKey (Object key ) {
90+ return LinkedCaseInsensitiveMap .this .containsKey (key );
91+ }
8892 @ Override
8993 protected boolean removeEldestEntry (Map .Entry <String , V > eldest ) {
9094 boolean doRemove = LinkedCaseInsensitiveMap .this .removeEldestEntry (eldest );
@@ -120,23 +124,35 @@ public boolean isEmpty() {
120124 }
121125
122126 @ Override
123- public boolean containsValue (Object value ) {
124- return this .targetMap . containsValue ( value );
127+ public boolean containsKey (Object key ) {
128+ return ( key instanceof String && this .caseInsensitiveKeys . containsKey ( convertKey (( String ) key )) );
125129 }
126130
127131 @ Override
128- public Set < String > keySet ( ) {
129- return this .targetMap .keySet ( );
132+ public boolean containsValue ( Object value ) {
133+ return this .targetMap .containsValue ( value );
130134 }
131135
132136 @ Override
133- public Collection <V > values () {
134- return this .targetMap .values ();
137+ public V get (Object key ) {
138+ if (key instanceof String ) {
139+ String caseInsensitiveKey = this .caseInsensitiveKeys .get (convertKey ((String ) key ));
140+ if (caseInsensitiveKey != null ) {
141+ return this .targetMap .get (caseInsensitiveKey );
142+ }
143+ }
144+ return null ;
135145 }
136146
137147 @ Override
138- public Set <Entry <String , V >> entrySet () {
139- return this .targetMap .entrySet ();
148+ public V getOrDefault (Object key , V defaultValue ) {
149+ if (key instanceof String ) {
150+ String caseInsensitiveKey = this .caseInsensitiveKeys .get (convertKey ((String ) key ));
151+ if (caseInsensitiveKey != null ) {
152+ return this .targetMap .get (caseInsensitiveKey );
153+ }
154+ }
155+ return defaultValue ;
140156 }
141157
142158 @ Override
@@ -158,33 +174,6 @@ public void putAll(Map<? extends String, ? extends V> map) {
158174 }
159175 }
160176
161- @ Override
162- public boolean containsKey (Object key ) {
163- return (key instanceof String && this .caseInsensitiveKeys .containsKey (convertKey ((String ) key )));
164- }
165-
166- @ Override
167- public V get (Object key ) {
168- if (key instanceof String ) {
169- String caseInsensitiveKey = this .caseInsensitiveKeys .get (convertKey ((String ) key ));
170- if (caseInsensitiveKey != null ) {
171- return this .targetMap .get (caseInsensitiveKey );
172- }
173- }
174- return null ;
175- }
176-
177- @ Override
178- public V getOrDefault (Object key , V defaultValue ) {
179- if (key instanceof String ) {
180- String caseInsensitiveKey = this .caseInsensitiveKeys .get (convertKey ((String ) key ));
181- if (caseInsensitiveKey != null ) {
182- return this .targetMap .get (caseInsensitiveKey );
183- }
184- }
185- return defaultValue ;
186- }
187-
188177 @ Override
189178 public V remove (Object key ) {
190179 if (key instanceof String ) {
@@ -202,6 +191,20 @@ public void clear() {
202191 this .targetMap .clear ();
203192 }
204193
194+ @ Override
195+ public Set <String > keySet () {
196+ return this .targetMap .keySet ();
197+ }
198+
199+ @ Override
200+ public Collection <V > values () {
201+ return this .targetMap .values ();
202+ }
203+
204+ @ Override
205+ public Set <Entry <String , V >> entrySet () {
206+ return this .targetMap .entrySet ();
207+ }
205208
206209 @ Override
207210 public LinkedCaseInsensitiveMap <V > clone () {
0 commit comments