View Javadoc
1   /*
2    * Copyright 2024 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.spdy;
17  
18  import io.netty.buffer.ByteBuf;
19  import io.netty.buffer.DefaultByteBufHolder;
20  import io.netty.util.internal.StringUtil;
21  
22  public final class DefaultSpdyUnknownFrame extends DefaultByteBufHolder implements SpdyUnknownFrame {
23      private final int frameType;
24      private final byte flags;
25  
26      public DefaultSpdyUnknownFrame(int frameType, byte flags, ByteBuf data) {
27          super(data);
28          this.frameType = frameType;
29          this.flags = flags;
30      }
31  
32      @Override
33      public int frameType() {
34          return frameType;
35      }
36  
37      @Override
38      public byte flags() {
39          return flags;
40      }
41  
42      @Override
43      public DefaultSpdyUnknownFrame copy() {
44          return replace(content().copy());
45      }
46  
47      @Override
48      public DefaultSpdyUnknownFrame duplicate() {
49          return replace(content().duplicate());
50      }
51  
52      @Override
53      public DefaultSpdyUnknownFrame retainedDuplicate() {
54          return replace(content().retainedDuplicate());
55      }
56  
57      @Override
58      public DefaultSpdyUnknownFrame replace(final ByteBuf content) {
59          return new DefaultSpdyUnknownFrame(frameType, flags, content);
60      }
61  
62      @Override
63      public DefaultSpdyUnknownFrame retain() {
64          super.retain();
65          return this;
66      }
67  
68      @Override
69      public DefaultSpdyUnknownFrame retain(final int increment) {
70          super.retain(increment);
71          return this;
72      }
73  
74      @Override
75      public DefaultSpdyUnknownFrame touch() {
76          super.touch();
77          return this;
78      }
79  
80      @Override
81      public DefaultSpdyUnknownFrame touch(final Object hint) {
82          super.touch(hint);
83          return this;
84      }
85  
86      @Override
87      public boolean equals(final Object o) {
88          if (!(o instanceof DefaultSpdyUnknownFrame)) {
89              return false;
90          }
91          final DefaultSpdyUnknownFrame that = (DefaultSpdyUnknownFrame) o;
92          return frameType == that.frameType
93              && flags == that.flags
94              && super.equals(that);
95      }
96  
97      @Override
98      public int hashCode() {
99          int result = super.hashCode();
100         result = 31 * result + frameType;
101         result = 31 * result + flags;
102         return result;
103     }
104 
105     @Override
106     public String toString() {
107         return StringUtil.simpleClassName(this) + "(" + "frameType=" + frameType +
108             ", flags=" + flags + ", content=" + contentToString() +
109             ')';
110     }
111 }