Rename fromByte() to valueOf()
Motivation: Persuit the consistency in method naming Modifications: Rename fromByte(byte) to valueOf(byte) Result: Consistency
This commit is contained in:
parent
0ef87697d5
commit
824662c6ef
@ -28,7 +28,15 @@ public enum SocksAddressType {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #valueOf(byte)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static SocksAddressType fromByte(byte b) {
|
||||
return valueOf(b);
|
||||
}
|
||||
|
||||
public static SocksAddressType valueOf(byte b) {
|
||||
for (SocksAddressType code : values()) {
|
||||
if (code.b == b) {
|
||||
return code;
|
||||
|
@ -42,7 +42,7 @@ public class SocksAuthRequestDecoder extends ReplayingDecoder<SocksAuthRequestDe
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out) throws Exception {
|
||||
switch (state()) {
|
||||
case CHECK_PROTOCOL_VERSION: {
|
||||
version = SocksSubnegotiationVersion.fromByte(byteBuf.readByte());
|
||||
version = SocksSubnegotiationVersion.valueOf(byteBuf.readByte());
|
||||
if (version != SocksSubnegotiationVersion.AUTH_PASSWORD) {
|
||||
break;
|
||||
}
|
||||
|
@ -40,14 +40,14 @@ public class SocksAuthResponseDecoder extends ReplayingDecoder<SocksAuthResponse
|
||||
throws Exception {
|
||||
switch (state()) {
|
||||
case CHECK_PROTOCOL_VERSION: {
|
||||
version = SocksSubnegotiationVersion.fromByte(byteBuf.readByte());
|
||||
version = SocksSubnegotiationVersion.valueOf(byteBuf.readByte());
|
||||
if (version != SocksSubnegotiationVersion.AUTH_PASSWORD) {
|
||||
break;
|
||||
}
|
||||
checkpoint(State.READ_AUTH_RESPONSE);
|
||||
}
|
||||
case READ_AUTH_RESPONSE: {
|
||||
authStatus = SocksAuthStatus.fromByte(byteBuf.readByte());
|
||||
authStatus = SocksAuthStatus.valueOf(byteBuf.readByte());
|
||||
msg = new SocksAuthResponse(authStatus);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,15 @@ public enum SocksAuthScheme {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #valueOf(byte)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static SocksAuthScheme fromByte(byte b) {
|
||||
return valueOf(b);
|
||||
}
|
||||
|
||||
public static SocksAuthScheme valueOf(byte b) {
|
||||
for (SocksAuthScheme code : values()) {
|
||||
if (code.b == b) {
|
||||
return code;
|
||||
|
@ -26,7 +26,15 @@ public enum SocksAuthStatus {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #valueOf(byte)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static SocksAuthStatus fromByte(byte b) {
|
||||
return valueOf(b);
|
||||
}
|
||||
|
||||
public static SocksAuthStatus valueOf(byte b) {
|
||||
for (SocksAuthStatus code : values()) {
|
||||
if (code.b == b) {
|
||||
return code;
|
||||
|
@ -52,9 +52,9 @@ public class SocksCmdRequestDecoder extends ReplayingDecoder<SocksCmdRequestDeco
|
||||
checkpoint(State.READ_CMD_HEADER);
|
||||
}
|
||||
case READ_CMD_HEADER: {
|
||||
cmdType = SocksCmdType.fromByte(byteBuf.readByte());
|
||||
cmdType = SocksCmdType.valueOf(byteBuf.readByte());
|
||||
reserved = byteBuf.readByte();
|
||||
addressType = SocksAddressType.fromByte(byteBuf.readByte());
|
||||
addressType = SocksAddressType.valueOf(byteBuf.readByte());
|
||||
checkpoint(State.READ_CMD_ADDRESS);
|
||||
}
|
||||
case READ_CMD_ADDRESS: {
|
||||
|
@ -45,16 +45,16 @@ public class SocksCmdResponseDecoder extends ReplayingDecoder<SocksCmdResponseDe
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out) throws Exception {
|
||||
switch (state()) {
|
||||
case CHECK_PROTOCOL_VERSION: {
|
||||
version = SocksProtocolVersion.fromByte(byteBuf.readByte());
|
||||
version = SocksProtocolVersion.valueOf(byteBuf.readByte());
|
||||
if (version != SocksProtocolVersion.SOCKS5) {
|
||||
break;
|
||||
}
|
||||
checkpoint(State.READ_CMD_HEADER);
|
||||
}
|
||||
case READ_CMD_HEADER: {
|
||||
cmdStatus = SocksCmdStatus.fromByte(byteBuf.readByte());
|
||||
cmdStatus = SocksCmdStatus.valueOf(byteBuf.readByte());
|
||||
reserved = byteBuf.readByte();
|
||||
addressType = SocksAddressType.fromByte(byteBuf.readByte());
|
||||
addressType = SocksAddressType.valueOf(byteBuf.readByte());
|
||||
checkpoint(State.READ_CMD_ADDRESS);
|
||||
}
|
||||
case READ_CMD_ADDRESS: {
|
||||
|
@ -34,7 +34,15 @@ public enum SocksCmdStatus {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #valueOf(byte)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static SocksCmdStatus fromByte(byte b) {
|
||||
return valueOf(b);
|
||||
}
|
||||
|
||||
public static SocksCmdStatus valueOf(byte b) {
|
||||
for (SocksCmdStatus code : values()) {
|
||||
if (code.b == b) {
|
||||
return code;
|
||||
|
@ -28,7 +28,15 @@ public enum SocksCmdType {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #valueOf(byte)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static SocksCmdType fromByte(byte b) {
|
||||
return valueOf(b);
|
||||
}
|
||||
|
||||
public static SocksCmdType valueOf(byte b) {
|
||||
for (SocksCmdType code : values()) {
|
||||
if (code.b == b) {
|
||||
return code;
|
||||
|
@ -41,7 +41,7 @@ public class SocksInitRequestDecoder extends ReplayingDecoder<SocksInitRequestDe
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out) throws Exception {
|
||||
switch (state()) {
|
||||
case CHECK_PROTOCOL_VERSION: {
|
||||
version = SocksProtocolVersion.fromByte(byteBuf.readByte());
|
||||
version = SocksProtocolVersion.valueOf(byteBuf.readByte());
|
||||
if (version != SocksProtocolVersion.SOCKS5) {
|
||||
break;
|
||||
}
|
||||
@ -51,7 +51,7 @@ public class SocksInitRequestDecoder extends ReplayingDecoder<SocksInitRequestDe
|
||||
authSchemes.clear();
|
||||
authSchemeNum = byteBuf.readByte();
|
||||
for (int i = 0; i < authSchemeNum; i++) {
|
||||
authSchemes.add(SocksAuthScheme.fromByte(byteBuf.readByte()));
|
||||
authSchemes.add(SocksAuthScheme.valueOf(byteBuf.readByte()));
|
||||
}
|
||||
msg = new SocksInitRequest(authSchemes);
|
||||
break;
|
||||
|
@ -40,14 +40,14 @@ public class SocksInitResponseDecoder extends ReplayingDecoder<SocksInitResponse
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out) throws Exception {
|
||||
switch (state()) {
|
||||
case CHECK_PROTOCOL_VERSION: {
|
||||
version = SocksProtocolVersion.fromByte(byteBuf.readByte());
|
||||
version = SocksProtocolVersion.valueOf(byteBuf.readByte());
|
||||
if (version != SocksProtocolVersion.SOCKS5) {
|
||||
break;
|
||||
}
|
||||
checkpoint(State.READ_PREFFERED_AUTH_TYPE);
|
||||
}
|
||||
case READ_PREFFERED_AUTH_TYPE: {
|
||||
authScheme = SocksAuthScheme.fromByte(byteBuf.readByte());
|
||||
authScheme = SocksAuthScheme.valueOf(byteBuf.readByte());
|
||||
msg = new SocksInitResponse(authScheme);
|
||||
break;
|
||||
}
|
||||
|
@ -27,7 +27,15 @@ public enum SocksProtocolVersion {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #valueOf(byte)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static SocksProtocolVersion fromByte(byte b) {
|
||||
return valueOf(b);
|
||||
}
|
||||
|
||||
public static SocksProtocolVersion valueOf(byte b) {
|
||||
for (SocksProtocolVersion code : values()) {
|
||||
if (code.b == b) {
|
||||
return code;
|
||||
|
@ -26,7 +26,15 @@ public enum SocksSubnegotiationVersion {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #valueOf(byte)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static SocksSubnegotiationVersion fromByte(byte b) {
|
||||
return valueOf(b);
|
||||
}
|
||||
|
||||
public static SocksSubnegotiationVersion valueOf(byte b) {
|
||||
for (SocksSubnegotiationVersion code : values()) {
|
||||
if (code.b == b) {
|
||||
return code;
|
||||
|
Loading…
Reference in New Issue
Block a user