Constraint.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:para 作者:
/**
 * Builds a new constraint from the annotation data.
 * @param anno JSR-303 annotation instance
 * @return a new constraint
 */
public static Constraint fromAnnotation(Annotation anno) {
    if (anno instanceof Min) {
        return min(((Min) anno).value());
    } else if (anno instanceof Max) {
        return max(((Max) anno).value());
    } else if (anno instanceof Size) {
        return size(((Size) anno).min(), ((Size) anno).max());
    } else if (anno instanceof Digits) {
        return digits(((Digits) anno).integer(), ((Digits) anno).fraction());
    } else if (anno instanceof Pattern) {
        return pattern(((Pattern) anno).regexp());
    } else {
        return new Constraint(VALIDATORS.get(anno.annotationType()),
                simplePayload(VALIDATORS.get(anno.annotationType()))) {
                    public boolean isValid(Object actualValue) {
                        return true;
                    }
                };
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号