Add 'static' modifier to the methods that don't need to be member methods

This commit is contained in:
Trustin Lee 2012-11-10 07:54:33 +09:00
parent 5a4b2ec07e
commit 05c416b674
4 changed files with 20 additions and 22 deletions

View File

@ -32,7 +32,7 @@ public final class CaseIgnoringComparator implements Comparator<String>, Seriali
return o1.compareToIgnoreCase(o2);
}
@SuppressWarnings("static-method")
@SuppressWarnings("MethodMayBeStatic")
private Object readResolve() {
return INSTANCE;
}

View File

@ -108,7 +108,7 @@ public class WebSocketServerHandshakerFactory {
* @param channel
* Channel
*/
public void sendUnsupportedWebSocketVersionResponse(Channel channel) {
public static void sendUnsupportedWebSocketVersionResponse(Channel channel) {
HttpResponse res = new DefaultHttpResponse(
HttpVersion.HTTP_1_1,
HttpResponseStatus.SWITCHING_PROTOCOLS);

View File

@ -15,12 +15,6 @@
*/
package io.netty.handler.codec.http.websocketx;
import static io.netty.handler.codec.http.HttpHeaders.Values.WEBSOCKET;
import static io.netty.handler.codec.http.HttpResponseStatus.SWITCHING_PROTOCOLS;
import static io.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN;
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import io.netty.buffer.MessageBuf;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandler;
@ -34,10 +28,13 @@ import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpRequestDecoder;
import io.netty.handler.codec.http.HttpResponse;
import io.netty.handler.codec.http.HttpResponseEncoder;
import io.netty.handler.codec.http.HttpResponseStatus;
import org.junit.Test;
import static io.netty.handler.codec.http.HttpHeaders.Values.*;
import static io.netty.handler.codec.http.HttpResponseStatus.*;
import static io.netty.handler.codec.http.HttpVersion.*;
import static org.junit.Assert.*;
public class WebSocketServerProtocolHandlerTest {
@Test
@ -76,7 +73,7 @@ public class WebSocketServerProtocolHandlerTest {
ch.writeInbound(httpRequest);
HttpResponse response = getHttpResponse(ch);
assertEquals(HttpResponseStatus.BAD_REQUEST, response.getStatus());
assertEquals(BAD_REQUEST, response.getStatus());
assertEquals("not a WebSocket handshake request: missing upgrade", getResponseMessage(response));
}
@ -96,7 +93,7 @@ public class WebSocketServerProtocolHandlerTest {
ch.writeInbound(httpRequest);
HttpResponse response = getHttpResponse(ch);
assertEquals(HttpResponseStatus.BAD_REQUEST, response.getStatus());
assertEquals(BAD_REQUEST, response.getStatus());
assertEquals("not a WebSocket request: missing key", getResponseMessage(response));
}
@ -113,11 +110,11 @@ public class WebSocketServerProtocolHandlerTest {
assertEquals("processed: payload", customTextFrameHandler.getContent());
}
private EmbeddedMessageChannel createChannel() {
private static EmbeddedMessageChannel createChannel() {
return createChannel(null);
}
private EmbeddedMessageChannel createChannel(ChannelHandler handler) {
private static EmbeddedMessageChannel createChannel(ChannelHandler handler) {
return new EmbeddedMessageChannel(
new WebSocketServerProtocolHandler("/test", null, false),
new HttpRequestDecoder(),
@ -126,15 +123,15 @@ public class WebSocketServerProtocolHandlerTest {
handler);
}
private void writeUpgradeRequest(EmbeddedMessageChannel ch) {
private static void writeUpgradeRequest(EmbeddedMessageChannel ch) {
ch.writeInbound(WebSocketRequestBuilder.sucessful());
}
private String getResponseMessage(HttpResponse response) {
private static String getResponseMessage(HttpResponse response) {
return new String(response.getContent().array());
}
private HttpResponse getHttpResponse(EmbeddedMessageChannel ch) {
private static HttpResponse getHttpResponse(EmbeddedMessageChannel ch) {
MessageBuf<Object> outbound = ch.pipeline().context(MockOutboundHandler.class).outboundMessageBuffer();
return (HttpResponse) outbound.poll();
}

View File

@ -15,7 +15,6 @@
*/
package io.netty.channel;
import static io.netty.channel.DefaultChannelHandlerContext.*;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ChannelBuf;
import io.netty.buffer.MessageBuf;
@ -34,6 +33,8 @@ import java.util.NoSuchElementException;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
import static io.netty.channel.DefaultChannelHandlerContext.*;
/**
* The default {@link ChannelPipeline} implementation. It is usually created
* by a {@link Channel} implementation when the {@link Channel} is created.
@ -920,7 +921,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
return nextOutboundByteBuffer(tail);
}
boolean hasNextOutboundByteBuffer(DefaultChannelHandlerContext ctx) {
static boolean hasNextOutboundByteBuffer(DefaultChannelHandlerContext ctx) {
for (;;) {
if (ctx == null) {
return false;
@ -933,7 +934,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
}
}
boolean hasNextOutboundMessageBuffer(DefaultChannelHandlerContext ctx) {
static boolean hasNextOutboundMessageBuffer(DefaultChannelHandlerContext ctx) {
for (;;) {
if (ctx == null) {
return false;
@ -946,7 +947,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
}
}
ByteBuf nextOutboundByteBuffer(DefaultChannelHandlerContext ctx) {
static ByteBuf nextOutboundByteBuffer(DefaultChannelHandlerContext ctx) {
final DefaultChannelHandlerContext initialCtx = ctx;
final Thread currentThread = Thread.currentThread();
for (;;) {
@ -982,7 +983,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
}
}
MessageBuf<Object> nextOutboundMessageBuffer(DefaultChannelHandlerContext ctx) {
static MessageBuf<Object> nextOutboundMessageBuffer(DefaultChannelHandlerContext ctx) {
final DefaultChannelHandlerContext initialCtx = ctx;
final Thread currentThread = Thread.currentThread();
for (;;) {