1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package org.apache.hc.core5.http.io.entity;
29
30 import org.apache.hc.core5.annotation.Contract;
31 import org.apache.hc.core5.annotation.ThreadingBehavior;
32 import org.apache.hc.core5.function.Supplier;
33 import org.apache.hc.core5.http.Header;
34 import org.apache.hc.core5.http.HttpEntity;
35
36 import java.io.IOException;
37 import java.io.InputStream;
38 import java.io.OutputStream;
39 import java.util.Collections;
40 import java.util.List;
41 import java.util.Set;
42
43
44
45
46
47
48
49 @Contract(threading = ThreadingBehavior.IMMUTABLE)
50 public final class NullEntity implements HttpEntity {
51
52 public static final NullEntity INSTANCE = new NullEntity();
53
54 private NullEntity() {}
55
56 @Override
57 public boolean isRepeatable() {
58 return true;
59 }
60
61 @Override
62 public InputStream getContent() throws IOException, UnsupportedOperationException {
63 return EmptyInputStream.INSTANCE;
64 }
65
66 @Override
67 public void writeTo(final OutputStream outStream) throws IOException {}
68
69 @Override
70 public boolean isStreaming() {
71 return false;
72 }
73
74 @Override
75 public Supplier<List<? extends Header>> getTrailers() {
76 return null;
77 }
78
79 @Override
80 public void close() throws IOException {}
81
82 @Override
83 public long getContentLength() {
84 return 0;
85 }
86
87 @Override
88 public String getContentType() {
89 return null;
90 }
91
92 @Override
93 public String getContentEncoding() {
94 return null;
95 }
96
97 @Override
98 public boolean isChunked() {
99 return false;
100 }
101
102 @Override
103 public Set<String> getTrailerNames() {
104 return Collections.emptySet();
105 }
106 }