Replace constructor calls on UniqueName and its subtypes with valueOf() wherever possible

This commit is contained in:
Trustin Lee 2013-10-25 20:58:53 +09:00
parent 8986245b47
commit 1c2352e6a0
8 changed files with 17 additions and 16 deletions

View File

@ -61,7 +61,7 @@ public class WebSocketServerProtocolHandler extends WebSocketProtocolHandler {
} }
private static final AttributeKey<WebSocketServerHandshaker> HANDSHAKER_ATTR_KEY = private static final AttributeKey<WebSocketServerHandshaker> HANDSHAKER_ATTR_KEY =
new AttributeKey<WebSocketServerHandshaker>(WebSocketServerHandshaker.class.getName()); AttributeKey.valueOf(WebSocketServerHandshaker.class.getName() + ".HANDSHAKER");
private final String websocketPath; private final String websocketPath;
private final String subprotocols; private final String subprotocols;

View File

@ -19,8 +19,8 @@ import io.netty.util.Signal;
public class DecoderResult { public class DecoderResult {
protected static final Signal SIGNAL_UNFINISHED = new Signal(DecoderResult.class.getName() + ".UNFINISHED"); protected static final Signal SIGNAL_UNFINISHED = Signal.valueOf(DecoderResult.class.getName() + ".UNFINISHED");
protected static final Signal SIGNAL_SUCCESS = new Signal(DecoderResult.class.getName() + ".SUCCESS"); protected static final Signal SIGNAL_SUCCESS = Signal.valueOf(DecoderResult.class.getName() + ".SUCCESS");
public static final DecoderResult UNFINISHED = new DecoderResult(SIGNAL_UNFINISHED); public static final DecoderResult UNFINISHED = new DecoderResult(SIGNAL_UNFINISHED);
public static final DecoderResult SUCCESS = new DecoderResult(SIGNAL_SUCCESS); public static final DecoderResult SUCCESS = new DecoderResult(SIGNAL_SUCCESS);

View File

@ -266,7 +266,7 @@ import java.util.List;
*/ */
public abstract class ReplayingDecoder<S> extends ByteToMessageDecoder { public abstract class ReplayingDecoder<S> extends ByteToMessageDecoder {
static final Signal REPLAY = new Signal(ReplayingDecoder.class.getName() + ".REPLAY"); static final Signal REPLAY = Signal.valueOf(ReplayingDecoder.class.getName() + ".REPLAY");
private final ReplayingDecoderBuffer replayable = new ReplayingDecoderBuffer(); private final ReplayingDecoderBuffer replayable = new ReplayingDecoderBuffer();
private S state; private S state;

View File

@ -20,7 +20,6 @@ import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.util.Attribute; import io.netty.util.Attribute;
import io.netty.util.AttributeKey; import io.netty.util.AttributeKey;
import org.jboss.marshalling.MarshallerFactory; import org.jboss.marshalling.MarshallerFactory;
import org.jboss.marshalling.MarshallingConfiguration; import org.jboss.marshalling.MarshallingConfiguration;
import org.jboss.marshalling.Unmarshaller; import org.jboss.marshalling.Unmarshaller;
@ -35,8 +34,8 @@ import org.jboss.marshalling.Unmarshaller;
*/ */
public class ContextBoundUnmarshallerProvider extends DefaultUnmarshallerProvider { public class ContextBoundUnmarshallerProvider extends DefaultUnmarshallerProvider {
private static final AttributeKey<Unmarshaller> UNMARSHALLER = new AttributeKey<Unmarshaller>( private static final AttributeKey<Unmarshaller> UNMARSHALLER = AttributeKey.valueOf(
ContextBoundUnmarshallerProvider.class.getName() + ".unmarshaller"); ContextBoundUnmarshallerProvider.class.getName() + ".UNMARSHALLER");
public ContextBoundUnmarshallerProvider(MarshallerFactory factory, MarshallingConfiguration config) { public ContextBoundUnmarshallerProvider(MarshallerFactory factory, MarshallingConfiguration config) {
super(factory, config); super(factory, config);

View File

@ -37,7 +37,7 @@ import java.io.Serializable;
public class CompatibleObjectEncoder extends MessageToByteEncoder<Serializable> { public class CompatibleObjectEncoder extends MessageToByteEncoder<Serializable> {
private static final AttributeKey<ObjectOutputStream> OOS = private static final AttributeKey<ObjectOutputStream> OOS =
new AttributeKey<ObjectOutputStream>(CompatibleObjectEncoder.class.getName() + ".oos"); AttributeKey.valueOf(CompatibleObjectEncoder.class.getName() + ".OOS");
private final int resetInterval; private final int resetInterval;
private int writtenObjects; private int writtenObjects;

View File

@ -39,8 +39,8 @@ public class DefaultPromise<V> extends AbstractFuture<V> implements Promise<V> {
return 0; return 0;
} }
}; };
private static final Signal SUCCESS = new Signal(DefaultPromise.class.getName() + ".SUCCESS"); private static final Signal SUCCESS = Signal.valueOf(DefaultPromise.class.getName() + ".SUCCESS");
private static final Signal UNCANCELLABLE = new Signal(DefaultPromise.class.getName() + ".UNCANCELLABLE"); private static final Signal UNCANCELLABLE = Signal.valueOf(DefaultPromise.class.getName() + ".UNCANCELLABLE");
private final EventExecutor executor; private final EventExecutor executor;
private volatile Object result; private volatile Object result;

View File

@ -15,11 +15,11 @@
*/ */
package io.netty.util; package io.netty.util;
import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*;
public class DefaultAttributeMapTest { public class DefaultAttributeMapTest {
private DefaultAttributeMap map; private DefaultAttributeMap map;
@ -36,7 +36,7 @@ public class DefaultAttributeMapTest {
@Test @Test
public void testGetSetString() { public void testGetSetString() {
AttributeKey<String> key = new AttributeKey<String>("Nothing"); AttributeKey<String> key = AttributeKey.valueOf("Nothing");
Attribute<String> one = map.attr(key); Attribute<String> one = map.attr(key);
assertSame(one, map.attr(key)); assertSame(one, map.attr(key));
@ -53,7 +53,7 @@ public class DefaultAttributeMapTest {
@Test @Test
public void testGetSetInt() { public void testGetSetInt() {
AttributeKey<Integer> key = new AttributeKey<Integer>("Nada"); AttributeKey<Integer> key = AttributeKey.valueOf("Nada");
Attribute<Integer> one = map.attr(key); Attribute<Integer> one = map.attr(key);
assertSame(one, map.attr(key)); assertSame(one, map.attr(key));

View File

@ -73,8 +73,10 @@ public abstract class AbstractTrafficShapingHandler extends ChannelDuplexHandler
*/ */
protected long checkInterval = DEFAULT_CHECK_INTERVAL; // default 1 s protected long checkInterval = DEFAULT_CHECK_INTERVAL; // default 1 s
private static final AttributeKey<Boolean> READ_SUSPENDED = new AttributeKey<Boolean>("readSuspended"); private static final AttributeKey<Boolean> READ_SUSPENDED = AttributeKey.valueOf(
private static final AttributeKey<Runnable> REOPEN_TASK = new AttributeKey<Runnable>("reopenTask"); AbstractTrafficShapingHandler.class.getName() + ".READ_SUSPENDED");
private static final AttributeKey<Runnable> REOPEN_TASK = AttributeKey.valueOf(
AbstractTrafficShapingHandler.class.getName() + ".REOPEN_TASK");
/** /**
* *