Skip to content

Commit

Permalink
Rename fromByte() to valueOf()
Browse files Browse the repository at this point in the history
Motivation:

Persuit the consistency in method naming

Modifications:

Rename fromByte(byte) to valueOf(byte)

Result:

Consistency
  • Loading branch information
trustin committed Jun 24, 2014
1 parent 0ef8769 commit 824662c
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public SocksAuthRequestDecoder() {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteB
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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> o
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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ public SocksCmdResponseDecoder() {
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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public SocksInitRequestDecoder() {
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;
}
Expand All @@ -51,7 +51,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> o
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public SocksInitResponseDecoder() {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 824662c

Please sign in to comment.