1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.netty5.handler.codec.http;
18
19 import java.util.Collections;
20 import java.util.Iterator;
21 import java.util.List;
22 import java.util.Map.Entry;
23 import java.util.Set;
24
25 public class EmptyHttpHeaders extends HttpHeaders {
26 private static final Iterator<Entry<CharSequence, CharSequence>> EMPTY_CHARS_ITERATOR =
27 Collections.emptyIterator();
28
29 public static final EmptyHttpHeaders INSTANCE = new EmptyHttpHeaders();
30
31 protected EmptyHttpHeaders() {
32 }
33
34 @Override
35 public String get(String name) {
36 return null;
37 }
38
39 @Override
40 public Integer getInt(CharSequence name) {
41 return null;
42 }
43
44 @Override
45 public int getInt(CharSequence name, int defaultValue) {
46 return defaultValue;
47 }
48
49 @Override
50 public Short getShort(CharSequence name) {
51 return null;
52 }
53
54 @Override
55 public short getShort(CharSequence name, short defaultValue) {
56 return defaultValue;
57 }
58
59 @Override
60 public Long getTimeMillis(CharSequence name) {
61 return null;
62 }
63
64 @Override
65 public long getTimeMillis(CharSequence name, long defaultValue) {
66 return defaultValue;
67 }
68
69 @Override
70 public List<String> getAll(String name) {
71 return Collections.emptyList();
72 }
73
74 @Override
75 public List<Entry<String, String>> entries() {
76 return Collections.emptyList();
77 }
78
79 @Override
80 public boolean contains(String name) {
81 return false;
82 }
83
84 @Override
85 public boolean isEmpty() {
86 return true;
87 }
88
89 @Override
90 public int size() {
91 return 0;
92 }
93
94 @Override
95 public Set<String> names() {
96 return Collections.emptySet();
97 }
98
99 @Override
100 public HttpHeaders add(String name, Object value) {
101 throw new UnsupportedOperationException("read only");
102 }
103
104 @Override
105 public HttpHeaders add(String name, Iterable<?> values) {
106 throw new UnsupportedOperationException("read only");
107 }
108
109 @Override
110 public HttpHeaders addInt(CharSequence name, int value) {
111 throw new UnsupportedOperationException("read only");
112 }
113
114 @Override
115 public HttpHeaders addShort(CharSequence name, short value) {
116 throw new UnsupportedOperationException("read only");
117 }
118
119 @Override
120 public HttpHeaders set(String name, Object value) {
121 throw new UnsupportedOperationException("read only");
122 }
123
124 @Override
125 public HttpHeaders set(String name, Iterable<?> values) {
126 throw new UnsupportedOperationException("read only");
127 }
128
129 @Override
130 public HttpHeaders setInt(CharSequence name, int value) {
131 throw new UnsupportedOperationException("read only");
132 }
133
134 @Override
135 public HttpHeaders setShort(CharSequence name, short value) {
136 throw new UnsupportedOperationException("read only");
137 }
138
139 @Override
140 public HttpHeaders remove(String name) {
141 throw new UnsupportedOperationException("read only");
142 }
143
144 @Override
145 public HttpHeaders clear() {
146 throw new UnsupportedOperationException("read only");
147 }
148
149 @Override
150 public Iterator<Entry<String, String>> iterator() {
151 return entries().iterator();
152 }
153
154 @Override
155 public Iterator<Entry<CharSequence, CharSequence>> iteratorCharSequence() {
156 return EMPTY_CHARS_ITERATOR;
157 }
158
159 }