View Javadoc
1   /*
2    * Copyright 2020 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.handler.codec.http3;
17  
18  import io.netty.buffer.ByteBuf;
19  import io.netty.buffer.DefaultByteBufHolder;
20  import io.netty.util.internal.StringUtil;
21  
22  import java.util.Objects;
23  
24  public final class DefaultHttp3UnknownFrame extends DefaultByteBufHolder implements Http3UnknownFrame {
25      private final long type;
26  
27      public DefaultHttp3UnknownFrame(long type, ByteBuf payload) {
28          super(payload);
29          this.type = Http3CodecUtils.checkIsReservedFrameType(type);
30      }
31  
32      @Override
33      public long type() {
34          return type;
35      }
36  
37      @Override
38      public Http3UnknownFrame copy() {
39          return new DefaultHttp3UnknownFrame(type, content().copy());
40      }
41  
42      @Override
43      public Http3UnknownFrame duplicate() {
44          return new DefaultHttp3UnknownFrame(type, content().duplicate());
45      }
46  
47      @Override
48      public Http3UnknownFrame retainedDuplicate() {
49          return new DefaultHttp3UnknownFrame(type, content().retainedDuplicate());
50      }
51  
52      @Override
53      public Http3UnknownFrame replace(ByteBuf content) {
54          return new DefaultHttp3UnknownFrame(type, content);
55      }
56  
57      @Override
58      public Http3UnknownFrame retain() {
59          super.retain();
60          return this;
61      }
62  
63      @Override
64      public Http3UnknownFrame retain(int increment) {
65          super.retain(increment);
66          return this;
67      }
68  
69      @Override
70      public Http3UnknownFrame touch() {
71          super.touch();
72          return this;
73      }
74  
75      @Override
76      public Http3UnknownFrame touch(Object hint) {
77          super.touch(hint);
78          return this;
79      }
80  
81      @Override
82      public String toString() {
83          return StringUtil.simpleClassName(this) + "(type=" + type() + ", content=" + content() + ')';
84      }
85  
86      @Override
87      public boolean equals(Object o) {
88          if (this == o) {
89              return true;
90          }
91          if (o == null || getClass() != o.getClass()) {
92              return false;
93          }
94          DefaultHttp3UnknownFrame that = (DefaultHttp3UnknownFrame) o;
95          if (type != that.type) {
96              return false;
97          }
98          return super.equals(o);
99      }
100 
101     @Override
102     public int hashCode() {
103         return Objects.hash(super.hashCode(), type);
104     }
105 }