Prettier string representation of ChannelEvent implementations
This commit is contained in:
parent
fff170b71e
commit
52e4288964
@ -69,10 +69,10 @@ public final class DefaultChildChannelStateEvent implements ChildChannelStateEve
|
||||
String channelString = getChannel().toString();
|
||||
StringBuilder buf = new StringBuilder(channelString.length() + 32);
|
||||
buf.append(channelString);
|
||||
buf.append(" - (childId: ");
|
||||
buf.append(getChildChannel().getId().toString());
|
||||
buf.append(", childState: ");
|
||||
buf.append(getChildChannel().isOpen()? "OPEN" : "CLOSED");
|
||||
buf.append(" - (");
|
||||
buf.append(getChildChannel().isOpen()? "CHILD_OPEN" : "CHILD_CLOSED");
|
||||
buf.append(": ");
|
||||
buf.append(getChildChannel().getId());
|
||||
buf.append(')');
|
||||
return buf.toString();
|
||||
}
|
||||
|
@ -69,6 +69,6 @@ public final class DefaultExceptionEvent implements ExceptionEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getChannel().toString() + " - (cause: " + cause.getClass().getSimpleName() + ')';
|
||||
return getChannel().toString() + " - (EXCEPTION: " + cause + ')';
|
||||
}
|
||||
}
|
||||
|
@ -67,12 +67,24 @@ public final class DefaultWriteCompletionEvent implements WriteCompletionEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String parentString = super.toString();
|
||||
StringBuilder buf = new StringBuilder(parentString.length() + 32);
|
||||
buf.append(parentString);
|
||||
buf.append(" - (writtenAmount: ");
|
||||
buf.append(getWrittenAmount());
|
||||
buf.append(')');
|
||||
String channelString = getChannel().toString();
|
||||
StringBuilder buf = new StringBuilder(channelString.length() + 32);
|
||||
buf.append(channelString);
|
||||
buf.append(" - (WROTE: ");
|
||||
|
||||
int amount = getWrittenAmount();
|
||||
switch (amount) {
|
||||
case 0:
|
||||
buf.append("0 byte");
|
||||
break;
|
||||
case 1:
|
||||
buf.append("1 byte");
|
||||
break;
|
||||
default:
|
||||
buf.append(amount);
|
||||
buf.append(" bytes");
|
||||
}
|
||||
buf.append(")");
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public final class DownstreamChannelStateEvent implements ChannelStateEvent {
|
||||
String channelString = getChannel().toString();
|
||||
StringBuilder buf = new StringBuilder(channelString.length() + 64);
|
||||
buf.append(channelString);
|
||||
buf.append(" - (request: ");
|
||||
buf.append(" - (");
|
||||
switch (getState()) {
|
||||
case OPEN:
|
||||
if (Boolean.TRUE.equals(getValue())) {
|
||||
@ -92,20 +92,23 @@ public final class DownstreamChannelStateEvent implements ChannelStateEvent {
|
||||
break;
|
||||
case BOUND:
|
||||
if (getValue() != null) {
|
||||
buf.append("BIND");
|
||||
buf.append("BIND: ");
|
||||
buf.append(getValue());
|
||||
} else {
|
||||
buf.append("UNBIND");
|
||||
}
|
||||
break;
|
||||
case CONNECTED:
|
||||
if (getValue() != null) {
|
||||
buf.append("CONNECT");
|
||||
buf.append("CONNECT: ");
|
||||
buf.append(getValue());
|
||||
} else {
|
||||
buf.append("DISCONNECT");
|
||||
}
|
||||
break;
|
||||
case INTEREST_OPS:
|
||||
buf.append("CHANGE_INTEREST");
|
||||
buf.append("CHANGE_INTEREST: ");
|
||||
buf.append(getValue());
|
||||
break;
|
||||
default:
|
||||
buf.append(getState().name());
|
||||
|
@ -85,9 +85,9 @@ public final class DownstreamMessageEvent implements MessageEvent {
|
||||
@Override
|
||||
public String toString() {
|
||||
if (remoteAddress == null) {
|
||||
return super.toString() + " - (write: " + message + ')';
|
||||
return getChannel().toString() + " - (WRITE: " + message + ')';
|
||||
} else {
|
||||
return super.toString() + " - (write: " + message + ", " + remoteAddress + ')';
|
||||
return getChannel().toString() + " - (WRITE: " + message + ", " + remoteAddress + ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public final class UpstreamChannelStateEvent implements ChannelStateEvent {
|
||||
String channelString = getChannel().toString();
|
||||
StringBuilder buf = new StringBuilder(channelString.length() + 64);
|
||||
buf.append(channelString);
|
||||
buf.append(" - (state: ");
|
||||
buf.append(" - (");
|
||||
switch (getState()) {
|
||||
case OPEN:
|
||||
if (Boolean.TRUE.equals(getValue())) {
|
||||
@ -89,14 +89,16 @@ public final class UpstreamChannelStateEvent implements ChannelStateEvent {
|
||||
break;
|
||||
case BOUND:
|
||||
if (getValue() != null) {
|
||||
buf.append("BOUND");
|
||||
buf.append("BOUND: ");
|
||||
buf.append(getValue());
|
||||
} else {
|
||||
buf.append("UNBOUND");
|
||||
}
|
||||
break;
|
||||
case CONNECTED:
|
||||
if (getValue() != null) {
|
||||
buf.append("CONNECTED");
|
||||
buf.append("CONNECTED: ");
|
||||
buf.append(getValue());
|
||||
} else {
|
||||
buf.append("DISCONNECTED");
|
||||
}
|
||||
|
@ -81,9 +81,9 @@ public final class UpstreamMessageEvent implements MessageEvent {
|
||||
@Override
|
||||
public String toString() {
|
||||
if (remoteAddress == null) {
|
||||
return super.toString() + " - (received: " + message + ')';
|
||||
return getChannel().toString() + " - (RECEIVED: " + message + ')';
|
||||
} else {
|
||||
return super.toString() + " - (received: " + message + ", " + remoteAddress + ')';
|
||||
return getChannel().toString() + " - (RECEIVED: " + message + ", " + remoteAddress + ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user