Rename ChannelGroupMatcher to ChannelMatcher

This commit is contained in:
Norman Maurer 2013-07-15 10:42:36 +02:00
parent df5daadd0f
commit d5f052f39c
4 changed files with 58 additions and 58 deletions

View File

@ -110,7 +110,7 @@ public interface ChannelGroup extends Set<Channel>, Comparable<ChannelGroup> {
/** /**
* Writes the specified {@code message} to all {@link Channel}s in this * Writes the specified {@code message} to all {@link Channel}s in this
* group that match the given {@link ChannelGroupMatcher}. If the specified {@code message} is an instance of * group that match the given {@link ChannelMatcher}. If the specified {@code message} is an instance of
* {@link ByteBuf}, it is automatically * {@link ByteBuf}, it is automatically
* {@linkplain ByteBuf#duplicate() duplicated} to avoid a race * {@linkplain ByteBuf#duplicate() duplicated} to avoid a race
* condition. The same is true for {@link ByteBufHolder}. Please note that this operation is asynchronous as * condition. The same is true for {@link ByteBufHolder}. Please note that this operation is asynchronous as
@ -119,7 +119,7 @@ public interface ChannelGroup extends Set<Channel>, Comparable<ChannelGroup> {
* @return the {@link ChannelGroupFuture} instance that notifies when * @return the {@link ChannelGroupFuture} instance that notifies when
* the operation is done for all channels * the operation is done for all channels
*/ */
ChannelGroupFuture write(Object message, ChannelGroupMatcher matcher); ChannelGroupFuture write(Object message, ChannelMatcher matcher);
/** /**
* Flush all {@link Channel}s in this * Flush all {@link Channel}s in this
@ -135,7 +135,7 @@ public interface ChannelGroup extends Set<Channel>, Comparable<ChannelGroup> {
ChannelGroup flush(); ChannelGroup flush();
/** /**
* Flush all {@link Channel}s in this group that match the given {@link ChannelGroupMatcher}. * Flush all {@link Channel}s in this group that match the given {@link ChannelMatcher}.
* If the specified {@code messages} are an instance of * If the specified {@code messages} are an instance of
* {@link ByteBuf}, it is automatically * {@link ByteBuf}, it is automatically
* {@linkplain ByteBuf#duplicate() duplicated} to avoid a race * {@linkplain ByteBuf#duplicate() duplicated} to avoid a race
@ -145,7 +145,7 @@ public interface ChannelGroup extends Set<Channel>, Comparable<ChannelGroup> {
* @return the {@link ChannelGroupFuture} instance that notifies when * @return the {@link ChannelGroupFuture} instance that notifies when
* the operation is done for all channels * the operation is done for all channels
*/ */
ChannelGroup flush(ChannelGroupMatcher matcher); ChannelGroup flush(ChannelMatcher matcher);
/** /**
* Shortcut for calling {@link #write(Object)} and {@link #flush()}. * Shortcut for calling {@link #write(Object)} and {@link #flush()}.
@ -154,9 +154,9 @@ public interface ChannelGroup extends Set<Channel>, Comparable<ChannelGroup> {
/** /**
* Shortcut for calling {@link #write(Object)} and {@link #flush()} and only act on * Shortcut for calling {@link #write(Object)} and {@link #flush()} and only act on
* {@link Channel}s that match the {@link ChannelGroupMatcher}. * {@link Channel}s that match the {@link ChannelMatcher}.
*/ */
ChannelGroupFuture flushAndWrite(Object message, ChannelGroupMatcher matcher); ChannelGroupFuture flushAndWrite(Object message, ChannelMatcher matcher);
/** /**
* Disconnects all {@link Channel}s in this group from their remote peers. * Disconnects all {@link Channel}s in this group from their remote peers.
@ -168,12 +168,12 @@ public interface ChannelGroup extends Set<Channel>, Comparable<ChannelGroup> {
/** /**
* Disconnects all {@link Channel}s in this group from their remote peers, * Disconnects all {@link Channel}s in this group from their remote peers,
* that match the given {@link ChannelGroupMatcher}. * that match the given {@link ChannelMatcher}.
* *
* @return the {@link ChannelGroupFuture} instance that notifies when * @return the {@link ChannelGroupFuture} instance that notifies when
* the operation is done for all channels * the operation is done for all channels
*/ */
ChannelGroupFuture disconnect(ChannelGroupMatcher matcher); ChannelGroupFuture disconnect(ChannelMatcher matcher);
/** /**
* Closes all {@link Channel}s in this group. If the {@link Channel} is * Closes all {@link Channel}s in this group. If the {@link Channel} is
@ -186,14 +186,14 @@ public interface ChannelGroup extends Set<Channel>, Comparable<ChannelGroup> {
ChannelGroupFuture close(); ChannelGroupFuture close();
/** /**
* Closes all {@link Channel}s in this group that match the given {@link ChannelGroupMatcher}. * Closes all {@link Channel}s in this group that match the given {@link ChannelMatcher}.
* If the {@link Channel} is connected to a remote peer or bound to a local address, it is * If the {@link Channel} is connected to a remote peer or bound to a local address, it is
* automatically disconnected and unbound. * automatically disconnected and unbound.
* *
* @return the {@link ChannelGroupFuture} instance that notifies when * @return the {@link ChannelGroupFuture} instance that notifies when
* the operation is done for all channels * the operation is done for all channels
*/ */
ChannelGroupFuture close(ChannelGroupMatcher matcher); ChannelGroupFuture close(ChannelMatcher matcher);
/** /**
* Deregister all {@link Channel}s in this group from their {@link EventLoop}. * Deregister all {@link Channel}s in this group from their {@link EventLoop}.
@ -206,10 +206,10 @@ public interface ChannelGroup extends Set<Channel>, Comparable<ChannelGroup> {
/** /**
* Deregister all {@link Channel}s in this group from their {@link EventLoop} that match the given * Deregister all {@link Channel}s in this group from their {@link EventLoop} that match the given
* {@link ChannelGroupMatcher}. Please note that this operation is asynchronous as {@link Channel#deregister()} is. * {@link ChannelMatcher}. Please note that this operation is asynchronous as {@link Channel#deregister()} is.
* *
* @return the {@link ChannelGroupFuture} instance that notifies when * @return the {@link ChannelGroupFuture} instance that notifies when
* the operation is done for all channels * the operation is done for all channels
*/ */
ChannelGroupFuture deregister(ChannelGroupMatcher matcher); ChannelGroupFuture deregister(ChannelMatcher matcher);
} }

View File

@ -21,9 +21,9 @@ import io.netty.channel.Channel;
/** /**
* Allows to only match some {@link Channel}'s for operations in {@link ChannelGroup}. * Allows to only match some {@link Channel}'s for operations in {@link ChannelGroup}.
* *
* {@link ChannelGroupMatchers} provide you with helper methods for usual needed implementations. * {@link ChannelMatchers} provide you with helper methods for usual needed implementations.
*/ */
public interface ChannelGroupMatcher { public interface ChannelMatcher {
/** /**
* Returns {@code true} if the operation should be also executed on the given {@link Channel}. * Returns {@code true} if the operation should be also executed on the given {@link Channel}.

View File

@ -19,88 +19,88 @@ import io.netty.channel.Channel;
import io.netty.channel.ServerChannel; import io.netty.channel.ServerChannel;
/** /**
* Helper class which provides often used {@link ChannelGroupMatcher} implementations. * Helper class which provides often used {@link ChannelMatcher} implementations.
*/ */
public final class ChannelGroupMatchers { public final class ChannelMatchers {
private static final ChannelGroupMatcher ALL_MATCHER = new ChannelGroupMatcher() { private static final ChannelMatcher ALL_MATCHER = new ChannelMatcher() {
@Override @Override
public boolean matches(Channel channel) { public boolean matches(Channel channel) {
return true; return true;
} }
}; };
private static final ChannelGroupMatcher SERVER_CHANNEL_MATCHER = isInstanceOf(ServerChannel.class); private static final ChannelMatcher SERVER_CHANNEL_MATCHER = isInstanceOf(ServerChannel.class);
private static final ChannelGroupMatcher NON_SERVER_CHANNEL_MATCHER = isNotInstanceOf(ServerChannel.class); private static final ChannelMatcher NON_SERVER_CHANNEL_MATCHER = isNotInstanceOf(ServerChannel.class);
private ChannelGroupMatchers() { private ChannelMatchers() {
// static methods only // static methods only
} }
/** /**
* Returns a {@link ChannelGroupMatcher} that matches all {@link Channel}s. * Returns a {@link ChannelMatcher} that matches all {@link Channel}s.
*/ */
public static ChannelGroupMatcher all() { public static ChannelMatcher all() {
return ALL_MATCHER; return ALL_MATCHER;
} }
/** /**
* Returns a {@link ChannelGroupMatcher} that matches all {@link Channel}s except the given. * Returns a {@link ChannelMatcher} that matches all {@link Channel}s except the given.
*/ */
public static ChannelGroupMatcher isNot(Channel channel) { public static ChannelMatcher isNot(Channel channel) {
return invert(is(channel)); return invert(is(channel));
} }
/** /**
* Returns a {@link ChannelGroupMatcher} that matches the given {@link Channel}. * Returns a {@link ChannelMatcher} that matches the given {@link Channel}.
*/ */
public static ChannelGroupMatcher is(Channel channel) { public static ChannelMatcher is(Channel channel) {
return new InstanceMatcher(channel); return new InstanceMatcher(channel);
} }
/** /**
* Returns a {@link ChannelGroupMatcher} that matches all {@link Channel}s that are an instance of sub-type of * Returns a {@link ChannelMatcher} that matches all {@link Channel}s that are an instance of sub-type of
* the given class. * the given class.
*/ */
public static ChannelGroupMatcher isInstanceOf(Class<? extends Channel> clazz) { public static ChannelMatcher isInstanceOf(Class<? extends Channel> clazz) {
return new ClassMatcher(clazz); return new ClassMatcher(clazz);
} }
/** /**
* Returns a {@link ChannelGroupMatcher} that matches all {@link Channel}s that are <strong>not</strong> an * Returns a {@link ChannelMatcher} that matches all {@link Channel}s that are <strong>not</strong> an
* instance of sub-type of the given class. * instance of sub-type of the given class.
*/ */
public static ChannelGroupMatcher isNotInstanceOf(Class<? extends Channel> clazz) { public static ChannelMatcher isNotInstanceOf(Class<? extends Channel> clazz) {
return invert(isInstanceOf(clazz)); return invert(isInstanceOf(clazz));
} }
/** /**
* Returns a {@link ChannelGroupMatcher} that matches all {@link Channel}s that are of type {@link ServerChannel}. * Returns a {@link ChannelMatcher} that matches all {@link Channel}s that are of type {@link ServerChannel}.
*/ */
public static ChannelGroupMatcher isServerChannel() { public static ChannelMatcher isServerChannel() {
return SERVER_CHANNEL_MATCHER; return SERVER_CHANNEL_MATCHER;
} }
/** /**
* Returns a {@link ChannelGroupMatcher} that matches all {@link Channel}s that are <strong>not</strong> of type * Returns a {@link ChannelMatcher} that matches all {@link Channel}s that are <strong>not</strong> of type
* {@link ServerChannel}. * {@link ServerChannel}.
*/ */
public static ChannelGroupMatcher isNonServerChannel() { public static ChannelMatcher isNonServerChannel() {
return NON_SERVER_CHANNEL_MATCHER; return NON_SERVER_CHANNEL_MATCHER;
} }
/** /**
* Invert the given {@link ChannelGroupMatcher}. * Invert the given {@link ChannelMatcher}.
*/ */
public static ChannelGroupMatcher invert(ChannelGroupMatcher matcher) { public static ChannelMatcher invert(ChannelMatcher matcher) {
return new InvertMatcher(matcher); return new InvertMatcher(matcher);
} }
/** /**
* Return a composite of the given {@link ChannelGroupMatcher}s. This means all {@link ChannelGroupMatcher} must * Return a composite of the given {@link ChannelMatcher}s. This means all {@link ChannelMatcher} must
* return {@code true} to match. * return {@code true} to match.
*/ */
public static ChannelGroupMatcher compose(ChannelGroupMatcher... matchers) { public static ChannelMatcher compose(ChannelMatcher... matchers) {
if (matchers.length < 1) { if (matchers.length < 1) {
throw new IllegalArgumentException("matchers must at least contain one element"); throw new IllegalArgumentException("matchers must at least contain one element");
} }
@ -110,10 +110,10 @@ public final class ChannelGroupMatchers {
return new CompositeMatcher(matchers); return new CompositeMatcher(matchers);
} }
private static final class CompositeMatcher implements ChannelGroupMatcher { private static final class CompositeMatcher implements ChannelMatcher {
private final ChannelGroupMatcher[] matchers; private final ChannelMatcher[] matchers;
CompositeMatcher(ChannelGroupMatcher... matchers) { CompositeMatcher(ChannelMatcher... matchers) {
this.matchers = matchers; this.matchers = matchers;
} }
@ -128,10 +128,10 @@ public final class ChannelGroupMatchers {
} }
} }
private static final class InvertMatcher implements ChannelGroupMatcher { private static final class InvertMatcher implements ChannelMatcher {
private final ChannelGroupMatcher matcher; private final ChannelMatcher matcher;
InvertMatcher(ChannelGroupMatcher matcher) { InvertMatcher(ChannelMatcher matcher) {
this.matcher = matcher; this.matcher = matcher;
} }
@ -141,7 +141,7 @@ public final class ChannelGroupMatchers {
} }
} }
private static final class InstanceMatcher implements ChannelGroupMatcher { private static final class InstanceMatcher implements ChannelMatcher {
private final Channel channel; private final Channel channel;
InstanceMatcher(Channel channel) { InstanceMatcher(Channel channel) {
@ -154,7 +154,7 @@ public final class ChannelGroupMatchers {
} }
} }
private static final class ClassMatcher implements ChannelGroupMatcher { private static final class ClassMatcher implements ChannelMatcher {
private final Class<? extends Channel> clazz; private final Class<? extends Channel> clazz;
ClassMatcher(Class<? extends Channel> clazz) { ClassMatcher(Class<? extends Channel> clazz) {

View File

@ -163,21 +163,21 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
@Override @Override
public ChannelGroupFuture close() { public ChannelGroupFuture close() {
return close(ChannelGroupMatchers.all()); return close(ChannelMatchers.all());
} }
@Override @Override
public ChannelGroupFuture disconnect() { public ChannelGroupFuture disconnect() {
return disconnect(ChannelGroupMatchers.all()); return disconnect(ChannelMatchers.all());
} }
@Override @Override
public ChannelGroupFuture deregister() { public ChannelGroupFuture deregister() {
return deregister(ChannelGroupMatchers.all()); return deregister(ChannelMatchers.all());
} }
@Override @Override
public ChannelGroupFuture write(Object message) { public ChannelGroupFuture write(Object message) {
return write(message, ChannelGroupMatchers.all()); return write(message, ChannelMatchers.all());
} }
// Create a safe duplicate of the message to write it to a channel but not affect other writes. // Create a safe duplicate of the message to write it to a channel but not affect other writes.
@ -193,7 +193,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
} }
@Override @Override
public ChannelGroupFuture write(Object message, ChannelGroupMatcher matcher) { public ChannelGroupFuture write(Object message, ChannelMatcher matcher) {
if (message == null) { if (message == null) {
throw new NullPointerException("message"); throw new NullPointerException("message");
} }
@ -214,16 +214,16 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
@Override @Override
public ChannelGroup flush() { public ChannelGroup flush() {
return flush(ChannelGroupMatchers.all()); return flush(ChannelMatchers.all());
} }
@Override @Override
public ChannelGroupFuture flushAndWrite(Object message) { public ChannelGroupFuture flushAndWrite(Object message) {
return flushAndWrite(message, ChannelGroupMatchers.all()); return flushAndWrite(message, ChannelMatchers.all());
} }
@Override @Override
public ChannelGroupFuture disconnect(ChannelGroupMatcher matcher) { public ChannelGroupFuture disconnect(ChannelMatcher matcher) {
if (matcher == null) { if (matcher == null) {
throw new NullPointerException("matcher"); throw new NullPointerException("matcher");
} }
@ -246,7 +246,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
} }
@Override @Override
public ChannelGroupFuture close(ChannelGroupMatcher matcher) { public ChannelGroupFuture close(ChannelMatcher matcher) {
if (matcher == null) { if (matcher == null) {
throw new NullPointerException("matcher"); throw new NullPointerException("matcher");
} }
@ -269,7 +269,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
} }
@Override @Override
public ChannelGroupFuture deregister(ChannelGroupMatcher matcher) { public ChannelGroupFuture deregister(ChannelMatcher matcher) {
if (matcher == null) { if (matcher == null) {
throw new NullPointerException("matcher"); throw new NullPointerException("matcher");
} }
@ -292,7 +292,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
} }
@Override @Override
public ChannelGroup flush(ChannelGroupMatcher matcher) { public ChannelGroup flush(ChannelMatcher matcher) {
for (Channel c: nonServerChannels) { for (Channel c: nonServerChannels) {
if (matcher.matches(c)) { if (matcher.matches(c)) {
c.flush(); c.flush();
@ -302,7 +302,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
} }
@Override @Override
public ChannelGroupFuture flushAndWrite(Object message, ChannelGroupMatcher matcher) { public ChannelGroupFuture flushAndWrite(Object message, ChannelMatcher matcher) {
if (message == null) { if (message == null) {
throw new NullPointerException("message"); throw new NullPointerException("message");
} }