Add inverting of validator, removes more boilerplate
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2023-01-21 22:12:56 +01:00
Ursprung b4df616bc4
Commit 2cbd7b8117

Datei anzeigen

@ -354,17 +354,21 @@ public abstract class AbstractSWCommand<T> {
boolean local() default false;
boolean invert() default false;
class Handler<T> implements AbstractValidator<T, Object> {
private AbstractValidator<T, Object> inner;
private boolean invert;
public Handler(AbstractSWCommand.Validator validator, Class<?> clazz, Map<String, AbstractValidator<T, ?>> localValidator) {
inner = (AbstractValidator<T, Object>) SWCommandUtils.getValidator(validator, clazz, localValidator);
invert = validator.invert();
}
@Override
public boolean validate(T sender, Object value, MessageSender messageSender) {
return inner.validate(sender, value, messageSender);
return inner.validate(sender, value, messageSender) ^ invert;
}
}
}