private final Error error = new ServerError().type(ProtocolType.CANCEL).add(NotAcceptable.DETAIL);
@Override
public boolean input(JIDContext context, Protocol protocol) {
Username username = protocol.cast(Register.class).findField(Username.NAME, Username.class);
return username != null && username.valid() ? true : this.writeAndReturn(context, protocol);
}
private boolean writeAndReturn(JIDContext context, Protocol protocol) {
context.write(protocol.parent().reply().setError(this.error));
return false;