Hide the constructors of ChannelOption to force using dedicated option type

This commit is contained in:
Trustin Lee 2013-01-17 14:14:41 +09:00
parent ad15155f04
commit f568aa42f0
4 changed files with 35 additions and 37 deletions

View File

@ -23,26 +23,26 @@ import io.netty.channel.rxtx.RxtxChannelConfig.Stopbits;
/**
* Option for configuring a serial port connection
*/
public final class RxtxChannelOption<T> extends ChannelOption<T> {
public static final ChannelOption<Integer> BAUD_RATE =
new ChannelOption<Integer>("BAUD_RATE");
public class RxtxChannelOption<T> extends ChannelOption<T> {
public static final RxtxChannelOption<Integer> BAUD_RATE =
new RxtxChannelOption<Integer>("BAUD_RATE");
public static final ChannelOption<Boolean> DTR =
new ChannelOption<Boolean>("DTR");
public static final RxtxChannelOption<Boolean> DTR =
new RxtxChannelOption<Boolean>("DTR");
public static final ChannelOption<Boolean> RTS =
new ChannelOption<Boolean>("RTS");
public static final RxtxChannelOption<Boolean> RTS =
new RxtxChannelOption<Boolean>("RTS");
public static final ChannelOption<Stopbits> STOP_BITS =
new ChannelOption<Stopbits>("STOP_BITS");
public static final RxtxChannelOption<Stopbits> STOP_BITS =
new RxtxChannelOption<Stopbits>("STOP_BITS");
public static final ChannelOption<Databits> DATA_BITS =
new ChannelOption<Databits>("DATA_BITS");
public static final RxtxChannelOption<Databits> DATA_BITS =
new RxtxChannelOption<Databits>("DATA_BITS");
public static final ChannelOption<Paritybit> PARITY_BIT =
new ChannelOption<Paritybit>("PARITY_BIT");
public static final RxtxChannelOption<Paritybit> PARITY_BIT =
new RxtxChannelOption<Paritybit>("PARITY_BIT");
public RxtxChannelOption(String name) {
private RxtxChannelOption(String name) {
super(name);
}
}

View File

@ -24,14 +24,14 @@ import java.util.List;
* Option for configuring the SCTP transport
*/
public class SctpChannelOption<T> extends ChannelOption<T> {
public static final ChannelOption<Boolean> SCTP_DISABLE_FRAGMENTS =
new ChannelOption<Boolean>("SCTP_DISABLE_FRAGMENTS");
public static final ChannelOption<Boolean> SCTP_EXPLICIT_COMPLETE =
new ChannelOption<Boolean>("SCTP_EXPLICIT_COMPLETE");
public static final ChannelOption<Integer> SCTP_FRAGMENT_INTERLEAVE =
new ChannelOption<Integer>("SCTP_FRAGMENT_INTERLEAVE");
public static final ChannelOption<List<Integer>> SCTP_INIT_MAXSTREAMS =
new ChannelOption<List<Integer>>("SCTP_INIT_MAXSTREAMS") {
public static final SctpChannelOption<Boolean> SCTP_DISABLE_FRAGMENTS =
new SctpChannelOption<Boolean>("SCTP_DISABLE_FRAGMENTS");
public static final SctpChannelOption<Boolean> SCTP_EXPLICIT_COMPLETE =
new SctpChannelOption<Boolean>("SCTP_EXPLICIT_COMPLETE");
public static final SctpChannelOption<Integer> SCTP_FRAGMENT_INTERLEAVE =
new SctpChannelOption<Integer>("SCTP_FRAGMENT_INTERLEAVE");
public static final SctpChannelOption<List<Integer>> SCTP_INIT_MAXSTREAMS =
new SctpChannelOption<List<Integer>>("SCTP_INIT_MAXSTREAMS") {
@Override
public void validate(List<Integer> value) {
super.validate(value);
@ -47,14 +47,14 @@ public class SctpChannelOption<T> extends ChannelOption<T> {
}
};
public static final ChannelOption<Boolean> SCTP_NODELAY =
new ChannelOption<Boolean>("SCTP_NODELAY");
public static final ChannelOption<SocketAddress> SCTP_PRIMARY_ADDR =
new ChannelOption<SocketAddress>("SCTP_PRIMARY_ADDR");
public static final ChannelOption<SocketAddress> SCTP_SET_PEER_PRIMARY_ADDR =
new ChannelOption<SocketAddress>("SCTP_SET_PEER_PRIMARY_ADDR");
public static final SctpChannelOption<Boolean> SCTP_NODELAY =
new SctpChannelOption<Boolean>("SCTP_NODELAY");
public static final SctpChannelOption<SocketAddress> SCTP_PRIMARY_ADDR =
new SctpChannelOption<SocketAddress>("SCTP_PRIMARY_ADDR");
public static final SctpChannelOption<SocketAddress> SCTP_SET_PEER_PRIMARY_ADDR =
new SctpChannelOption<SocketAddress>("SCTP_SET_PEER_PRIMARY_ADDR");
public SctpChannelOption(String name) {
private SctpChannelOption(String name) {
super(name);
}
}

View File

@ -26,28 +26,28 @@ public class UdtChannelOption<T> extends ChannelOption<T> {
/**
* See {@link OptionUDT#Protocol_Receive_Buffer_Size}.
*/
public static final ChannelOption<Integer> PROTOCOL_RECEIVE_BUFFER_SIZE = new ChannelOption<Integer>(
public static final UdtChannelOption<Integer> PROTOCOL_RECEIVE_BUFFER_SIZE = new UdtChannelOption<Integer>(
"PROTOCOL_RECEIVE_BUFFER_SIZE");
/**
* See {@link OptionUDT#Protocol_Send_Buffer_Size}.
*/
public static final ChannelOption<Integer> PROTOCOL_SEND_BUFFER_SIZE = new ChannelOption<Integer>(
public static final UdtChannelOption<Integer> PROTOCOL_SEND_BUFFER_SIZE = new UdtChannelOption<Integer>(
"PROTOCOL_SEND_BUFFER_SIZE");
/**
* See {@link OptionUDT#System_Receive_Buffer_Size}.
*/
public static final ChannelOption<Integer> SYSTEM_RECEIVE_BUFFER_SIZE = new ChannelOption<Integer>(
public static final UdtChannelOption<Integer> SYSTEM_RECEIVE_BUFFER_SIZE = new UdtChannelOption<Integer>(
"SYSTEM_RECEIVE_BUFFER_SIZE");
/**
* See {@link OptionUDT#System_Send_Buffer_Size}.
*/
public static final ChannelOption<Integer> SYSTEM_SEND_BUFFER_SIZE = new ChannelOption<Integer>(
public static final UdtChannelOption<Integer> SYSTEM_SEND_BUFFER_SIZE = new UdtChannelOption<Integer>(
"SYSTEM_SEND_BUFFER_SIZE");
public UdtChannelOption(String name) {
private UdtChannelOption(String name) {
super(name);
}
}

View File

@ -85,16 +85,14 @@ public class ChannelOption<T> extends UniqueName {
/**
* Create a new {@link ChannelOption} with the given name. The name needs to be
* unique.
*
*/
public ChannelOption(String name) {
protected ChannelOption(String name) {
super(names, name);
}
/**
* Validate the value which is set for the {@link ChannelOption}. Sub-classes
* may override this for special checks.
*
*/
public void validate(T value) {
if (value == null) {