CMDAPIRework #25
@ -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