1
1
/*
2
- * Copyright 2002-2016 the original author or authors.
2
+ * Copyright 2002-2017 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -85,6 +85,10 @@ public LinkedCaseInsensitiveMap(int initialCapacity) {
85
85
*/
86
86
public LinkedCaseInsensitiveMap (int initialCapacity , Locale locale ) {
87
87
this .targetMap = new LinkedHashMap <String , V >(initialCapacity ) {
88
+ @ Override
89
+ public boolean containsKey (Object key ) {
90
+ return LinkedCaseInsensitiveMap .this .containsKey (key );
91
+ }
88
92
@ Override
89
93
protected boolean removeEldestEntry (Map .Entry <String , V > eldest ) {
90
94
boolean doRemove = LinkedCaseInsensitiveMap .this .removeEldestEntry (eldest );
@@ -120,23 +124,35 @@ public boolean isEmpty() {
120
124
}
121
125
122
126
@ 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 )) );
125
129
}
126
130
127
131
@ Override
128
- public Set < String > keySet ( ) {
129
- return this .targetMap .keySet ( );
132
+ public boolean containsValue ( Object value ) {
133
+ return this .targetMap .containsValue ( value );
130
134
}
131
135
132
136
@ 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 ;
135
145
}
136
146
137
147
@ 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 ;
140
156
}
141
157
142
158
@ Override
@@ -158,33 +174,6 @@ public void putAll(Map<? extends String, ? extends V> map) {
158
174
}
159
175
}
160
176
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
-
188
177
@ Override
189
178
public V remove (Object key ) {
190
179
if (key instanceof String ) {
@@ -202,6 +191,20 @@ public void clear() {
202
191
this .targetMap .clear ();
203
192
}
204
193
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
+ }
205
208
206
209
@ Override
207
210
public LinkedCaseInsensitiveMap <V > clone () {
0 commit comments