Add inverting of validator, removes more boilerplate
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Ursprung
b4df616bc4
Commit
2cbd7b8117
@ -354,17 +354,21 @@ public abstract class AbstractSWCommand<T> {
|
|||||||
|
|
||||||
boolean local() default false;
|
boolean local() default false;
|
||||||
|
|
||||||
|
boolean invert() default false;
|
||||||
|
|
||||||
class Handler<T> implements AbstractValidator<T, Object> {
|
class Handler<T> implements AbstractValidator<T, Object> {
|
||||||
|
|
||||||
private AbstractValidator<T, Object> inner;
|
private AbstractValidator<T, Object> inner;
|
||||||
|
private boolean invert;
|
||||||
|
|
||||||
public Handler(AbstractSWCommand.Validator validator, Class<?> clazz, Map<String, AbstractValidator<T, ?>> localValidator) {
|
public Handler(AbstractSWCommand.Validator validator, Class<?> clazz, Map<String, AbstractValidator<T, ?>> localValidator) {
|
||||||
inner = (AbstractValidator<T, Object>) SWCommandUtils.getValidator(validator, clazz, localValidator);
|
inner = (AbstractValidator<T, Object>) SWCommandUtils.getValidator(validator, clazz, localValidator);
|
||||||
|
invert = validator.invert();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean validate(T sender, Object value, MessageSender messageSender) {
|
public boolean validate(T sender, Object value, MessageSender messageSender) {
|
||||||
return inner.validate(sender, value, messageSender);
|
return inner.validate(sender, value, messageSender) ^ invert;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren