View Javadoc
1   /*
2    * Copyright 2016 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License, version 2.0 (the
5    * "License"); you may not use this file except in compliance with the License. You may obtain a
6    * 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 distributed under the License
11   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing permissions and limitations under
13   * the License.
14   */
15  
16  package io.netty.handler.codec.redis;
17  
18  import io.netty.buffer.ByteBuf;
19  import io.netty.buffer.DefaultByteBufHolder;
20  import io.netty.util.internal.StringUtil;
21  import io.netty.util.internal.UnstableApi;
22  
23  /**
24   * A default implementation of {@link BulkStringRedisContent}.
25   */
26  @UnstableApi
27  public class DefaultBulkStringRedisContent extends DefaultByteBufHolder implements BulkStringRedisContent {
28  
29      /**
30       * Creates a {@link DefaultBulkStringRedisContent} for the given {@code content}.
31       *
32       * @param content the content, can be {@code null}.
33       */
34      public DefaultBulkStringRedisContent(ByteBuf content) {
35          super(content);
36      }
37  
38      @Override
39      public BulkStringRedisContent copy() {
40          return (BulkStringRedisContent) super.copy();
41      }
42  
43      @Override
44      public BulkStringRedisContent duplicate() {
45          return (BulkStringRedisContent) super.duplicate();
46      }
47  
48      @Override
49      public BulkStringRedisContent retainedDuplicate() {
50          return (BulkStringRedisContent) super.retainedDuplicate();
51      }
52  
53      @Override
54      public BulkStringRedisContent replace(ByteBuf content) {
55          return new DefaultBulkStringRedisContent(content);
56      }
57  
58      @Override
59      public BulkStringRedisContent retain() {
60          super.retain();
61          return this;
62      }
63  
64      @Override
65      public BulkStringRedisContent retain(int increment) {
66          super.retain(increment);
67          return this;
68      }
69  
70      @Override
71      public BulkStringRedisContent touch() {
72          super.touch();
73          return this;
74      }
75  
76      @Override
77      public BulkStringRedisContent touch(Object hint) {
78          super.touch(hint);
79          return this;
80      }
81  
82      @Override
83      public String toString() {
84          return new StringBuilder(StringUtil.simpleClassName(this))
85                  .append('[')
86                  .append("content=")
87                  .append(content())
88                  .append(']').toString();
89      }
90  }