We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
`import java.lang.annotation.Annotation; import java.util.HashMap; import java.util.List; import java.util.Map;
import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Min;
public class ValidX {
public interface IValidator { /** * * @param root * @param ruleIdent 通过外部规则文件处理 * @param groups */ void valid(Object root, String ruleIdent, Class<?> ... groups); /** * * @param root * @param equityClass 对等规则类型 如果第三方类不方便修改 可以自己定义一个对等的 * @param class2 */ void valid(Object root, Class<A> equityClass, Class<?> ... groups); } public interface IValidMetaDataProvider { List<ValidMetaData> getTopValidMetaData(String rootRuleIdent, Class<?> ... groups) ; List<ValidMetaData> getAttrValidMetaData(String rootRuleIdent,String attrPath, Class<?> ... groups) ; //通过指定注释名称 和属性值 构建一个注解对象实例 //让通过配置配置的规则和直接写在类上的注解一致 <A extends Annotation > A pretendAnnotation(Class<A> annotationType,Map<String,Object> annotationValues); } public interface ValidMetaData { Annotation getRuleAnnotation(); } public interface ValidGroupA { } public interface ValidGroupB { } class Cxt{ } class IValidatorImpl implements IValidator{ IValidMetaDataProvider validMetaDataProvider; @Override public void valid(Object root, String ruleIdent, Class<?>... groups) { //定级规则 对应 class 上的验证规则 Cxt cxt = new Cxt(); List<ValidMetaData> topRules = validMetaDataProvider.getTopValidMetaData(ruleIdent, groups); for (ValidMetaData validMetaData : topRules) { exec(root,validMetaData,cxt); } //对应属性上的规则 List<String > attrs = getAttrs(root); for (String attrPath : attrs) { Object value = getAttrValue(root,attrPath); List<ValidMetaData> lis= validMetaDataProvider.getAttrValidMetaData( ruleIdent, attrPath, groups) ; for (ValidMetaData validMetaData : lis) { exec(root,attrPath,value,validMetaData,cxt); } } } private void exec(Object root, String attrPath, Object value, ValidMetaData validMetaData, Cxt cxt) { } private Object getAttrValue(Object object, String attrPath) { return null; } private void exec(Object object, ValidMetaData validMetaData, Cxt cxt) { java.lang.annotation.Annotation annotation = validMetaData.getRuleAnnotation(); } @Override public void valid(Object root, Class<A> equityClass, Class<?>... groups) { // TODO Auto-generated method stub } } class A{ @Min(value = 1L) @Max(value = 100L) Integer intVal; } void valid() { IValidator validator =newValidator(); IValidMetaDataProvider validMetaDataProvider = null ; Map<String,Object> obj = new HashMap<String, Object>(); obj.put("intVal", 1); /* * 验证规则标识 :{ intVal:[ { ann:"jakarta.validation.constraints.Min", attrs:{value:1L} },{ ann:"jakarta.validation.constraints.Max", attrs:{value:100L} } ] } * */ validator.valid(obj,"验证规则标识",ValidGroupA.class); validator.valid(obj,A.class,ValidGroupA.class); } public List<String> getAttrs(Object object) { return null; } private IValidator newValidator() { return null; }
} `
The text was updated successfully, but these errors were encountered:
No branches or pull requests
`import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
public class ValidX {
}
`
The text was updated successfully, but these errors were encountered: