Fix ErrorMessage annotation and ClassValidator never being present on Parameter
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Ursprung
19e4949048
Commit
2e9e4e2e49
@ -135,14 +135,6 @@ public class SWCommandUtils {
|
||||
public static <T> AbstractValidator<T, ?> getValidator(Parameter parameter, Map<String, AbstractValidator<T, ?>> localValidator) {
|
||||
Class<?> clazz = parameter.getType();
|
||||
|
||||
AbstractSWCommand.ClassValidator classValidator = parameter.getAnnotation(AbstractSWCommand.ClassValidator.class);
|
||||
if (classValidator != null) {
|
||||
if (classValidator.value() != null) {
|
||||
return getValidator(classValidator.value().getTypeName(), localValidator);
|
||||
}
|
||||
return getValidator(clazz.getTypeName(), localValidator);
|
||||
}
|
||||
|
||||
AbstractSWCommand.Validator validator = parameter.getAnnotation(AbstractSWCommand.Validator.class);
|
||||
if (validator != null) {
|
||||
if (validator.value() != null && !validator.value().isEmpty()) {
|
||||
@ -150,7 +142,10 @@ public class SWCommandUtils {
|
||||
}
|
||||
return getValidator(clazz.getTypeName(), localValidator);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> AbstractValidator<T, ?> getErrorMessage(Parameter parameter) {
|
||||
AbstractSWCommand.ErrorMessage errorMessage = parameter.getAnnotation(AbstractSWCommand.ErrorMessage.class);
|
||||
if (errorMessage != null) {
|
||||
return (AbstractValidator<T, Object>) (sender, value, messageSender) -> {
|
||||
|
@ -155,6 +155,7 @@ public class SubCommand<T> {
|
||||
commandPart.addValidator((AbstractValidator<T, Object>) STRING_SPACE_FILTER);
|
||||
}
|
||||
commandPart.addValidator(validator);
|
||||
commandPart.addValidator((AbstractValidator<T, Object>) SWCommandUtils.getErrorMessage(parameter));
|
||||
if (min != null) {
|
||||
commandPart.addValidator((AbstractValidator<T, Object>) createMinValidator(varArgType != null ? varArgType : parameter.getType(), min));
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren