1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty5.handler.codec.http2;
17
18 import io.netty5.util.internal.StringUtil;
19 import io.netty5.util.internal.UnstableApi;
20
21 import static java.util.Objects.requireNonNull;
22
23
24
25
26 @UnstableApi
27 public final class DefaultHttp2ResetFrame extends AbstractHttp2StreamFrame implements Http2ResetFrame {
28
29 private final long errorCode;
30
31
32
33
34
35
36 public DefaultHttp2ResetFrame(Http2Error error) {
37 errorCode = requireNonNull(error, "error").code();
38 }
39
40
41
42
43
44
45 public DefaultHttp2ResetFrame(long errorCode) {
46 this.errorCode = errorCode;
47 }
48
49 @Override
50 public DefaultHttp2ResetFrame stream(Http2FrameStream stream) {
51 super.stream(stream);
52 return this;
53 }
54
55 @Override
56 public String name() {
57 return "RST_STREAM";
58 }
59
60 @Override
61 public long errorCode() {
62 return errorCode;
63 }
64
65 @Override
66 public String toString() {
67 return StringUtil.simpleClassName(this) + "(stream=" + stream() + ", errorCode=" + errorCode + ')';
68 }
69
70 @Override
71 public boolean equals(Object o) {
72 if (!(o instanceof DefaultHttp2ResetFrame)) {
73 return false;
74 }
75 DefaultHttp2ResetFrame other = (DefaultHttp2ResetFrame) o;
76 return super.equals(o) && errorCode == other.errorCode;
77 }
78
79 @Override
80 public int hashCode() {
81 int hash = super.hashCode();
82 hash = hash * 31 + (int) (errorCode ^ errorCode >>> 32);
83 return hash;
84 }
85 }