View Javadoc
1   /*
2    * Copyright 2014 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License, version 2.0 (the
5    * "License"); you may not use this file except in compliance with the License. You may obtain a
6    * copy of the License at:
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software distributed under the License
11   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing permissions and limitations under
13   * the License.
14   */
15  package io.netty.handler.codec;
16  
17  import java.util.Collections;
18  import java.util.Comparator;
19  import java.util.Iterator;
20  import java.util.List;
21  import java.util.Map.Entry;
22  import java.util.Set;
23  
24  public class EmptyHeaders<T> implements Headers<T> {
25      @Override
26      public T get(T name) {
27          return null;
28      }
29  
30      @Override
31      public T get(T name, T defaultValue) {
32          return null;
33      }
34  
35      @Override
36      public T getAndRemove(T name) {
37          return null;
38      }
39  
40      @Override
41      public T getAndRemove(T name, T defaultValue) {
42          return null;
43      }
44  
45      @Override
46      public List<T> getAll(T name) {
47          return Collections.emptyList();
48      }
49  
50      @Override
51      public List<T> getAllAndRemove(T name) {
52          return Collections.emptyList();
53      }
54  
55      @Override
56      public Boolean getBoolean(T name) {
57          return null;
58      }
59  
60      @Override
61      public boolean getBoolean(T name, boolean defaultValue) {
62          return defaultValue;
63      }
64  
65      @Override
66      public Byte getByte(T name) {
67          return null;
68      }
69  
70      @Override
71      public byte getByte(T name, byte defaultValue) {
72          return defaultValue;
73      }
74  
75      @Override
76      public Character getChar(T name) {
77          return null;
78      }
79  
80      @Override
81      public char getChar(T name, char defaultValue) {
82          return defaultValue;
83      }
84  
85      @Override
86      public Short getShort(T name) {
87          return null;
88      }
89  
90      @Override
91      public short getInt(T name, short defaultValue) {
92          return defaultValue;
93      }
94  
95      @Override
96      public Integer getInt(T name) {
97          return null;
98      }
99  
100     @Override
101     public int getInt(T name, int defaultValue) {
102         return defaultValue;
103     }
104 
105     @Override
106     public Long getLong(T name) {
107         return null;
108     }
109 
110     @Override
111     public long getLong(T name, long defaultValue) {
112         return defaultValue;
113     }
114 
115     @Override
116     public Float getFloat(T name) {
117         return null;
118     }
119 
120     @Override
121     public float getFloat(T name, float defaultValue) {
122         return defaultValue;
123     }
124 
125     @Override
126     public Double getDouble(T name) {
127         return null;
128     }
129 
130     @Override
131     public double getDouble(T name, double defaultValue) {
132         return defaultValue;
133     }
134 
135     @Override
136     public Long getTimeMillis(T name) {
137         return null;
138     }
139 
140     @Override
141     public long getTimeMillis(T name, long defaultValue) {
142         return defaultValue;
143     }
144 
145     @Override
146     public Boolean getBooleanAndRemove(T name) {
147         return null;
148     }
149 
150     @Override
151     public boolean getBooleanAndRemove(T name, boolean defaultValue) {
152         return defaultValue;
153     }
154 
155     @Override
156     public Byte getByteAndRemove(T name) {
157         return null;
158     }
159 
160     @Override
161     public byte getByteAndRemove(T name, byte defaultValue) {
162         return defaultValue;
163     }
164 
165     @Override
166     public Character getCharAndRemove(T name) {
167         return null;
168     }
169 
170     @Override
171     public char getCharAndRemove(T name, char defaultValue) {
172         return defaultValue;
173     }
174 
175     @Override
176     public Short getShortAndRemove(T name) {
177         return null;
178     }
179 
180     @Override
181     public short getShortAndRemove(T name, short defaultValue) {
182         return defaultValue;
183     }
184 
185     @Override
186     public Integer getIntAndRemove(T name) {
187         return null;
188     }
189 
190     @Override
191     public int getIntAndRemove(T name, int defaultValue) {
192         return defaultValue;
193     }
194 
195     @Override
196     public Long getLongAndRemove(T name) {
197         return null;
198     }
199 
200     @Override
201     public long getLongAndRemove(T name, long defaultValue) {
202         return defaultValue;
203     }
204 
205     @Override
206     public Float getFloatAndRemove(T name) {
207         return null;
208     }
209 
210     @Override
211     public float getFloatAndRemove(T name, float defaultValue) {
212         return defaultValue;
213     }
214 
215     @Override
216     public Double getDoubleAndRemove(T name) {
217         return null;
218     }
219 
220     @Override
221     public double getDoubleAndRemove(T name, double defaultValue) {
222         return defaultValue;
223     }
224 
225     @Override
226     public Long getTimeMillisAndRemove(T name) {
227         return null;
228     }
229 
230     @Override
231     public long getTimeMillisAndRemove(T name, long defaultValue) {
232         return defaultValue;
233     }
234 
235     @Override
236     public List<Entry<T, T>> entries() {
237         return Collections.emptyList();
238     }
239 
240     @Override
241     public boolean contains(T name) {
242         return false;
243     }
244 
245     @Override
246     public boolean contains(T name, T value) {
247         return false;
248     }
249 
250     @Override
251     public boolean containsObject(T name, Object value) {
252         return false;
253     }
254 
255     @Override
256     public boolean containsBoolean(T name, boolean value) {
257         return false;
258     }
259 
260     @Override
261     public boolean containsByte(T name, byte value) {
262         return false;
263     }
264 
265     @Override
266     public boolean containsChar(T name, char value) {
267         return false;
268     }
269 
270     @Override
271     public boolean containsShort(T name, short value) {
272         return false;
273     }
274 
275     @Override
276     public boolean containsInt(T name, int value) {
277         return false;
278     }
279 
280     @Override
281     public boolean containsLong(T name, long value) {
282         return false;
283     }
284 
285     @Override
286     public boolean containsFloat(T name, float value) {
287         return false;
288     }
289 
290     @Override
291     public boolean containsDouble(T name, double value) {
292         return false;
293     }
294 
295     @Override
296     public boolean containsTimeMillis(T name, long value) {
297         return false;
298     }
299 
300     @Override
301     public boolean contains(T name, T value, Comparator<? super T> comparator) {
302         return false;
303     }
304 
305     @Override
306     public boolean contains(T name, T value,
307             Comparator<? super T> keyComparator, Comparator<? super T> valueComparator) {
308         return false;
309     }
310 
311     @Override
312     public boolean containsObject(T name, Object value, Comparator<? super T> comparator) {
313         return false;
314     }
315 
316     @Override
317     public boolean containsObject(T name, Object value, Comparator<? super T> keyComparator,
318             Comparator<? super T> valueComparator) {
319         return false;
320     }
321 
322     @Override
323     public int size() {
324         return 0;
325     }
326 
327     @Override
328     public boolean isEmpty() {
329         return true;
330     }
331 
332     @Override
333     public Set<T> names() {
334         return Collections.emptySet();
335     }
336 
337     @Override
338     public List<T> namesList() {
339         return Collections.emptyList();
340     }
341 
342     @Override
343     public Headers<T> add(T name, T value) {
344         throw new UnsupportedOperationException("read only");
345     }
346 
347     @Override
348     public Headers<T> add(T name, Iterable<? extends T> values) {
349         throw new UnsupportedOperationException("read only");
350     }
351 
352     @Override
353     public Headers<T> add(T name, T... values) {
354         throw new UnsupportedOperationException("read only");
355     }
356 
357     @Override
358     public Headers<T> addObject(T name, Object value) {
359         throw new UnsupportedOperationException("read only");
360     }
361 
362     @Override
363     public Headers<T> addObject(T name, Iterable<?> values) {
364         throw new UnsupportedOperationException("read only");
365     }
366 
367     @Override
368     public Headers<T> addObject(T name, Object... values) {
369         throw new UnsupportedOperationException("read only");
370     }
371 
372     @Override
373     public Headers<T> addBoolean(T name, boolean value) {
374         throw new UnsupportedOperationException("read only");
375     }
376 
377     @Override
378     public Headers<T> addByte(T name, byte value) {
379         throw new UnsupportedOperationException("read only");
380     }
381 
382     @Override
383     public Headers<T> addChar(T name, char value) {
384         throw new UnsupportedOperationException("read only");
385     }
386 
387     @Override
388     public Headers<T> addShort(T name, short value) {
389         throw new UnsupportedOperationException("read only");
390     }
391 
392     @Override
393     public Headers<T> addInt(T name, int value) {
394         throw new UnsupportedOperationException("read only");
395     }
396 
397     @Override
398     public Headers<T> addLong(T name, long value) {
399         throw new UnsupportedOperationException("read only");
400     }
401 
402     @Override
403     public Headers<T> addFloat(T name, float value) {
404         throw new UnsupportedOperationException("read only");
405     }
406 
407     @Override
408     public Headers<T> addDouble(T name, double value) {
409         throw new UnsupportedOperationException("read only");
410     }
411 
412     @Override
413     public Headers<T> addTimeMillis(T name, long value) {
414         throw new UnsupportedOperationException("read only");
415     }
416 
417     @Override
418     public Headers<T> add(Headers<T> headers) {
419         throw new UnsupportedOperationException("read only");
420     }
421 
422     @Override
423     public Headers<T> set(T name, T value) {
424         throw new UnsupportedOperationException("read only");
425     }
426 
427     @Override
428     public Headers<T> set(T name, Iterable<? extends T> values) {
429         throw new UnsupportedOperationException("read only");
430     }
431 
432     @Override
433     public Headers<T> set(T name, T... values) {
434         throw new UnsupportedOperationException("read only");
435     }
436 
437     @Override
438     public Headers<T> setObject(T name, Object value) {
439         throw new UnsupportedOperationException("read only");
440     }
441 
442     @Override
443     public Headers<T> setObject(T name, Iterable<?> values) {
444         throw new UnsupportedOperationException("read only");
445     }
446 
447     @Override
448     public Headers<T> setObject(T name, Object... values) {
449         throw new UnsupportedOperationException("read only");
450     }
451 
452     @Override
453     public Headers<T> setBoolean(T name, boolean value) {
454         throw new UnsupportedOperationException("read only");
455     }
456 
457     @Override
458     public Headers<T> setByte(T name, byte value) {
459         throw new UnsupportedOperationException("read only");
460     }
461 
462     @Override
463     public Headers<T> setChar(T name, char value) {
464         throw new UnsupportedOperationException("read only");
465     }
466 
467     @Override
468     public Headers<T> setShort(T name, short value) {
469         throw new UnsupportedOperationException("read only");
470     }
471 
472     @Override
473     public Headers<T> setInt(T name, int value) {
474         throw new UnsupportedOperationException("read only");
475     }
476 
477     @Override
478     public Headers<T> setLong(T name, long value) {
479         throw new UnsupportedOperationException("read only");
480     }
481 
482     @Override
483     public Headers<T> setFloat(T name, float value) {
484         throw new UnsupportedOperationException("read only");
485     }
486 
487     @Override
488     public Headers<T> setDouble(T name, double value) {
489         throw new UnsupportedOperationException("read only");
490     }
491 
492     @Override
493     public Headers<T> setTimeMillis(T name, long value) {
494         throw new UnsupportedOperationException("read only");
495     }
496 
497     @Override
498     public Headers<T> set(Headers<T> headers) {
499         throw new UnsupportedOperationException("read only");
500     }
501 
502     @Override
503     public Headers<T> setAll(Headers<T> headers) {
504         throw new UnsupportedOperationException("read only");
505     }
506 
507     @Override
508     public boolean remove(T name) {
509         return false;
510     }
511 
512     @Override
513     public Headers<T> clear() {
514         return this;
515     }
516 
517     @Override
518     public Iterator<Entry<T, T>> iterator() {
519         return entries().iterator();
520     }
521 
522     @Override
523     public Entry<T, T> forEachEntry(Headers.EntryVisitor<T> visitor) throws Exception {
524         return null;
525     }
526 
527     @Override
528     public T forEachName(Headers.NameVisitor<T> visitor) throws Exception {
529         return null;
530     }
531 
532     @Override
533     public boolean equals(Object o) {
534         if (!(o instanceof Headers)) {
535             return false;
536         }
537 
538         Headers<?> rhs = (Headers<?>) o;
539         return isEmpty() && rhs.isEmpty();
540     }
541 
542     @Override
543     public int hashCode() {
544         return 1;
545     }
546 
547     @Override
548     public String toString() {
549         return new StringBuilder(getClass().getSimpleName()).append('[').append(']').toString();
550     }
551 }