View Javadoc
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  package io.netty.handler.codec.memcache;
17  
18  import io.netty.buffer.ByteBuf;
19  import io.netty.buffer.Unpooled;
20  import io.netty.handler.codec.DecoderResult;
21  import io.netty.util.internal.UnstableApi;
22  
23  /**
24   * The {@link MemcacheContent} which signals the end of the content batch.
25   * <p/>
26   * Note that by design, even when no content is emitted by the protocol, an
27   * empty {@link LastMemcacheContent} is issued to make the upstream parsing
28   * easier.
29   */
30  @UnstableApi
31  public interface LastMemcacheContent extends MemcacheContent {
32  
33      LastMemcacheContent EMPTY_LAST_CONTENT = new LastMemcacheContent() {
34  
35          @Override
36          public LastMemcacheContent copy() {
37              return EMPTY_LAST_CONTENT;
38          }
39  
40          @Override
41          public LastMemcacheContent duplicate() {
42              return this;
43          }
44  
45          @Override
46          public LastMemcacheContent retainedDuplicate() {
47              return this;
48          }
49  
50          @Override
51          public LastMemcacheContent replace(ByteBuf content) {
52              return new DefaultLastMemcacheContent(content);
53          }
54  
55          @Override
56          public LastMemcacheContent retain(int increment) {
57              return this;
58          }
59  
60          @Override
61          public LastMemcacheContent retain() {
62              return this;
63          }
64  
65          @Override
66          public LastMemcacheContent touch() {
67              return this;
68          }
69  
70          @Override
71          public LastMemcacheContent touch(Object hint) {
72              return this;
73          }
74  
75          @Override
76          public ByteBuf content() {
77              return Unpooled.EMPTY_BUFFER;
78          }
79  
80          @Override
81          public DecoderResult decoderResult() {
82              return DecoderResult.SUCCESS;
83          }
84  
85          @Override
86          public void setDecoderResult(DecoderResult result) {
87              throw new UnsupportedOperationException("read only");
88          }
89  
90          @Override
91          public int refCnt() {
92              return 1;
93          }
94  
95          @Override
96          public boolean release() {
97              return false;
98          }
99  
100         @Override
101         public boolean release(int decrement) {
102             return false;
103         }
104     };
105 
106     @Override
107     LastMemcacheContent copy();
108 
109     @Override
110     LastMemcacheContent duplicate();
111 
112     @Override
113     LastMemcacheContent retainedDuplicate();
114 
115     @Override
116     LastMemcacheContent replace(ByteBuf content);
117 
118     @Override
119     LastMemcacheContent retain(int increment);
120 
121     @Override
122     LastMemcacheContent retain();
123 
124     @Override
125     LastMemcacheContent touch();
126 
127     @Override
128     LastMemcacheContent touch(Object hint);
129 }