All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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 getAnnotation() {
        return NotEmpty.class;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy