1 /*
2  * Copyright 2013 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  *   http://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 
17 module hunt.net.buffer.AbstractDerivedByteBuf;
18 
19 import hunt.net.buffer.AbstractByteBuf;
20 import hunt.net.buffer.ByteBuf;
21 
22 import hunt.io.ByteBuffer;
23 
24 /**
25  * Abstract base class for {@link ByteBuf} implementations that wrap another
26  * {@link ByteBuf}.
27  *
28  * deprecated("") Do not use.
29  */
30 abstract class AbstractDerivedByteBuf : AbstractByteBuf {
31 
32     protected this(int maxCapacity) {
33         super(maxCapacity);
34     }
35 
36     override
37     final bool isAccessible() {
38         return unwrap().isAccessible();
39     }
40 
41     // override
42     final int refCnt() {
43         return refCnt0();
44     }
45 
46     int refCnt0() {
47         return unwrap().refCnt();
48     }
49 
50     override
51     final ByteBuf retain() {
52         return retain0();
53     }
54 
55     ByteBuf retain0() {
56         unwrap().retain();
57         return this;
58     }
59 
60     override
61     final ByteBuf retain(int increment) {
62         return retain0(increment);
63     }
64 
65     ByteBuf retain0(int increment) {
66         unwrap().retain(increment);
67         return this;
68     }
69 
70     override
71     final ByteBuf touch() {
72         return touch0();
73     }
74 
75     ByteBuf touch0() {
76         unwrap().touch();
77         return this;
78     }
79 
80     override
81     final ByteBuf touch(Object hint) {
82         return touch0(hint);
83     }
84 
85     ByteBuf touch0(Object hint) {
86         unwrap().touch(hint);
87         return this;
88     }
89 
90     // override
91     final bool release() {
92         return release0();
93     }
94 
95     bool release0() {
96         return unwrap().release();
97     }
98 
99     // override
100     final bool release(int decrement) {
101         return release0(decrement);
102     }
103 
104     bool release0(int decrement) {
105         return unwrap().release(decrement);
106     }
107 
108     override
109     bool isReadOnly() {
110         return unwrap().isReadOnly();
111     }
112 
113     override
114     ByteBuffer internalNioBuffer(int index, int length) {
115         return nioBuffer(index, length);
116     }
117 
118     override
119     ByteBuffer nioBuffer(int index, int length) {
120         return unwrap().nioBuffer(index, length);
121     }
122 }