1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.codec.http2;
17
18 import io.netty.buffer.ByteBuf;
19 import io.netty.buffer.DefaultByteBufHolder;
20 import io.netty.buffer.Unpooled;
21 import io.netty.util.internal.StringUtil;
22 import io.netty.util.internal.UnstableApi;
23
24 @UnstableApi
25 public final class DefaultHttp2UnknownFrame extends DefaultByteBufHolder implements Http2UnknownFrame {
26 private final byte frameType;
27 private final Http2Flags flags;
28 private Http2FrameStream stream;
29
30 public DefaultHttp2UnknownFrame(byte frameType, Http2Flags flags) {
31 this(frameType, flags, Unpooled.EMPTY_BUFFER);
32 }
33
34 public DefaultHttp2UnknownFrame(byte frameType, Http2Flags flags, ByteBuf data) {
35 super(data);
36 this.frameType = frameType;
37 this.flags = flags;
38 }
39
40 @Override
41 public Http2FrameStream stream() {
42 return stream;
43 }
44
45 @Override
46 public DefaultHttp2UnknownFrame stream(Http2FrameStream stream) {
47 this.stream = stream;
48 return this;
49 }
50
51 @Override
52 public byte frameType() {
53 return frameType;
54 }
55
56 @Override
57 public Http2Flags flags() {
58 return flags;
59 }
60
61 @Override
62 public String name() {
63 return "UNKNOWN";
64 }
65
66 @Override
67 public DefaultHttp2UnknownFrame copy() {
68 return replace(content().copy());
69 }
70
71 @Override
72 public DefaultHttp2UnknownFrame duplicate() {
73 return replace(content().duplicate());
74 }
75
76 @Override
77 public DefaultHttp2UnknownFrame retainedDuplicate() {
78 return replace(content().retainedDuplicate());
79 }
80
81 @Override
82 public DefaultHttp2UnknownFrame replace(ByteBuf content) {
83 return new DefaultHttp2UnknownFrame(frameType, flags, content).stream(stream);
84 }
85
86 @Override
87 public DefaultHttp2UnknownFrame retain() {
88 super.retain();
89 return this;
90 }
91
92 @Override
93 public DefaultHttp2UnknownFrame retain(int increment) {
94 super.retain(increment);
95 return this;
96 }
97
98 @Override
99 public String toString() {
100 return StringUtil.simpleClassName(this) + "(frameType=" + frameType + ", stream=" + stream +
101 ", flags=" + flags + ", content=" + contentToString() + ')';
102 }
103
104 @Override
105 public DefaultHttp2UnknownFrame touch() {
106 super.touch();
107 return this;
108 }
109
110 @Override
111 public DefaultHttp2UnknownFrame touch(Object hint) {
112 super.touch(hint);
113 return this;
114 }
115
116 @Override
117 public boolean equals(Object o) {
118 if (!(o instanceof DefaultHttp2UnknownFrame)) {
119 return false;
120 }
121 DefaultHttp2UnknownFrame other = (DefaultHttp2UnknownFrame) o;
122 Http2FrameStream otherStream = other.stream();
123 return (stream == otherStream || otherStream != null && otherStream.equals(stream))
124 && flags.equals(other.flags())
125 && frameType == other.frameType()
126 && super.equals(other);
127 }
128
129 @Override
130 public int hashCode() {
131 int hash = super.hashCode();
132 hash = hash * 31 + frameType;
133 hash = hash * 31 + flags.hashCode();
134 if (stream != null) {
135 hash = hash * 31 + stream.hashCode();
136 }
137
138 return hash;
139 }
140 }