top.wboost.common.annotation.parameter.NotEmptyChecker Maven / Gradle / Ivy
package top.wboost.common.annotation.parameter;
import java.lang.annotation.Annotation;
import top.wboost.common.base.annotation.AutoWebApplicationConfig;
import top.wboost.common.util.Checker;
import top.wboost.common.util.StringUtil;
@AutoWebApplicationConfig
public class NotEmptyChecker implements ParameterConfigChecker {
@Override
public Boolean check(Object source, Object... argName) {
if (source instanceof String) {
Checker.hasText(source, argName[0].toString());
} else {
Checker.notNull(source, argName[0].toString());
}
return true;
}
@Override
public Boolean check(Object source, Annotation annotation, Object... args) {
NotEmpty notempty = (NotEmpty) annotation;
if (StringUtil.notEmpty(notempty.value())) {
check(source, notempty.value());
} else {
check(source, args);
}
return true;
}
@Override
public Class extends Annotation> getAnnotation() {
return NotEmpty.class;
}
}