View Javadoc
1   /*
2    * Copyright 2016 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.channel.group;
17  
18  import io.netty.channel.Channel;
19  import io.netty.channel.ChannelFuture;
20  import io.netty.util.concurrent.Future;
21  import io.netty.util.concurrent.GenericFutureListener;
22  
23  import java.util.Collections;
24  import java.util.Iterator;
25  import java.util.concurrent.TimeUnit;
26  
27  final class VoidChannelGroupFuture implements ChannelGroupFuture {
28  
29      private static final Iterator<ChannelFuture> EMPTY = Collections.<ChannelFuture>emptyList().iterator();
30      private final ChannelGroup group;
31  
32      VoidChannelGroupFuture(ChannelGroup group) {
33          this.group = group;
34      }
35  
36      @Override
37      public ChannelGroup group() {
38          return group;
39      }
40  
41      @Override
42      public ChannelFuture find(Channel channel) {
43          return null;
44      }
45  
46      @Override
47      public boolean isSuccess() {
48          return false;
49      }
50  
51      @Override
52      public ChannelGroupException cause() {
53          return null;
54      }
55  
56      @Override
57      public boolean isPartialSuccess() {
58          return false;
59      }
60  
61      @Override
62      public boolean isPartialFailure() {
63          return false;
64      }
65  
66      @Override
67      public ChannelGroupFuture addListener(GenericFutureListener<? extends Future<? super Void>> listener) {
68          throw reject();
69      }
70  
71      @Override
72      public ChannelGroupFuture addListeners(GenericFutureListener<? extends Future<? super Void>>... listeners) {
73          throw reject();
74      }
75  
76      @Override
77      public ChannelGroupFuture removeListener(GenericFutureListener<? extends Future<? super Void>> listener) {
78          throw reject();
79      }
80  
81      @Override
82      public ChannelGroupFuture removeListeners(GenericFutureListener<? extends Future<? super Void>>... listeners) {
83          throw reject();
84      }
85  
86      @Override
87      public ChannelGroupFuture await() {
88          throw reject();
89      }
90  
91      @Override
92      public ChannelGroupFuture awaitUninterruptibly() {
93          throw reject();
94      }
95  
96      @Override
97      public ChannelGroupFuture syncUninterruptibly() {
98          throw reject();
99      }
100 
101     @Override
102     public ChannelGroupFuture sync() {
103         throw reject();
104     }
105 
106     @Override
107     public Iterator<ChannelFuture> iterator() {
108         return EMPTY;
109     }
110 
111     @Override
112     public boolean isCancellable() {
113         return false;
114     }
115 
116     @Override
117     public boolean await(long timeout, TimeUnit unit) {
118         throw reject();
119     }
120 
121     @Override
122     public boolean await(long timeoutMillis) {
123         throw reject();
124     }
125 
126     @Override
127     public boolean awaitUninterruptibly(long timeout, TimeUnit unit) {
128         throw reject();
129     }
130 
131     @Override
132     public boolean awaitUninterruptibly(long timeoutMillis) {
133         throw reject();
134     }
135 
136     @Override
137     public Void getNow() {
138         return null;
139     }
140 
141     /**
142      * {@inheritDoc}
143      *
144      * @param mayInterruptIfRunning this value has no effect in this implementation.
145      */
146     @Override
147     public boolean cancel(boolean mayInterruptIfRunning) {
148         return false;
149     }
150 
151     @Override
152     public boolean isCancelled() {
153         return false;
154     }
155 
156     @Override
157     public boolean isDone() {
158         return false;
159     }
160 
161     @Override
162     public Void get() {
163         throw reject();
164     }
165 
166     @Override
167     public Void get(long timeout, TimeUnit unit)  {
168         throw reject();
169     }
170 
171     private static RuntimeException reject() {
172         return new IllegalStateException("void future");
173     }
174 }