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
22
23
24 @UnstableApi
25 public class DefaultHttp2PingFrame implements Http2PingFrame {
26
27 private final long content;
28 private final boolean ack;
29
30 public DefaultHttp2PingFrame(long content) {
31 this(content, false);
32 }
33
34 public DefaultHttp2PingFrame(long content, boolean ack) {
35 this.content = content;
36 this.ack = ack;
37 }
38
39 @Override
40 public boolean ack() {
41 return ack;
42 }
43
44 @Override
45 public String name() {
46 return "PING";
47 }
48
49 @Override
50 public long content() {
51 return content;
52 }
53
54 @Override
55 public boolean equals(Object o) {
56 if (!(o instanceof Http2PingFrame)) {
57 return false;
58 }
59 Http2PingFrame other = (Http2PingFrame) o;
60 return ack == other.ack() && content == other.content();
61 }
62
63 @Override
64 public int hashCode() {
65 int hash = super.hashCode();
66 hash = hash * 31 + (ack ? 1 : 0);
67 return hash;
68 }
69
70 @Override
71 public String toString() {
72 return StringUtil.simpleClassName(this) + "(content=" + content + ", ack=" + ack + ')';
73 }
74 }