当前位置: 首页>>代码示例>>Java>>正文


Java NotBlank类代码示例

本文整理汇总了Java中org.netbeans.bean.validation.constraints.NotBlank的典型用法代码示例。如果您正苦于以下问题:Java NotBlank类的具体用法?Java NotBlank怎么用?Java NotBlank使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NotBlank类属于org.netbeans.bean.validation.constraints包,在下文中一共展示了NotBlank类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAllConstraintsClass

import org.netbeans.bean.validation.constraints.NotBlank; //导入依赖的package包/类
/**
 * Complete list of constraint class based
 */
private static Map<Class<? extends Constraint>, Integer> getAllConstraintsClass() {
    Map<Class<? extends Constraint>, Integer> classes = new HashMap<>();
    classes.put(Null.class,             1);
    classes.put(NotNull.class,          2);
    classes.put(NotEmpty.class,         3);
    classes.put(NotBlank.class,         4);
    classes.put(AssertFalse.class,      5);
    classes.put(AssertTrue.class,       6);
    classes.put(Past.class,             7);
    classes.put(PastOrPresent.class,    8);
    classes.put(Future.class,           9);
    classes.put(FutureOrPresent.class,  10);
    classes.put(Size.class,             11);
    classes.put(Pattern.class,          12);
    classes.put(Email.class,            13);
    classes.put(Min.class,              14);
    classes.put(Max.class,              15);
    classes.put(DecimalMin.class,       16);
    classes.put(DecimalMax.class,       17);
    classes.put(Digits.class,           18);
    classes.put(Negative.class,         19);
    classes.put(NegativeOrZero.class,   20);
    classes.put(Positive.class,         21);
    classes.put(PositiveOrZero.class,   22);
    return classes;
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:30,代码来源:Attribute.java

示例2: loadValidation

import org.netbeans.bean.validation.constraints.NotBlank; //导入依赖的package包/类
private void loadValidation(Map<String, Constraint> constraints) {
        List<String> validationRules = new ArrayList<>();

        NotNull notNull = (NotNull) constraints.get(NotNull.class.getSimpleName());
        if (notNull != null && notNull.getSelected()) {
            validationRules.add("required");
        }
        
        NotEmpty notEmpty = (NotEmpty) constraints.get(NotEmpty.class.getSimpleName());
        if (notEmpty != null && notEmpty.getSelected()) {
            validationRules.add("required");
        }
        
        NotBlank notBlank = (NotBlank) constraints.get(NotBlank.class.getSimpleName());
        if (notBlank != null && notBlank.getSelected()) {
            validationRules.add("required");
        }

        Pattern pattern = (Pattern) constraints.get(Pattern.class.getSimpleName());
        if (pattern != null && pattern.getSelected()) {
            validationRules.add("pattern");
            fieldValidateRulesPattern = pattern.getRegexp();
        }
        
//        Email email = (Email) constraints.get(Email.class.getSimpleName());
//        if (email != null && email.getSelected()) {
//            validationRules.add("pattern");
//            fieldValidateRulesPattern = "/^\\[email protected][a-zA-Z_]+?\\.[a-zA-Z]{2,3}$/";
//        }

        Min min = (Min) constraints.get(Min.class.getSimpleName());
        if (min != null && min.getSelected()) {
            validationRules.add("min");
            fieldValidateRulesMin = String.valueOf(min.getValue());
        }

        Max max = (Max) constraints.get(Max.class.getSimpleName());
        if (max != null && max.getSelected()) {
            validationRules.add("max");
            fieldValidateRulesMax = String.valueOf(max.getValue());
        }

        if (constraints.get(Size.class.getSimpleName()) != null) {
            Size size = (Size) constraints.get(Size.class.getSimpleName());
            if (size.getMax() != null) {
                fieldValidateRulesMaxlength = String.valueOf(size.getMax());
                validationRules.add("maxlength");
            }
            if (size.getMin() != null) {
                fieldValidateRulesMinlength = String.valueOf(size.getMin());
                validationRules.add("minlength");
            }
        }
        setFieldValidate(validationRules);
    }
 
开发者ID:jeddict,项目名称:hipee,代码行数:56,代码来源:NGField.java

示例3: NotBlankSnippet

import org.netbeans.bean.validation.constraints.NotBlank; //导入依赖的package包/类
public NotBlankSnippet(NotBlank notBlank) {
    super(notBlank);
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:4,代码来源:NotBlankSnippet.java

示例4: getInstance

import org.netbeans.bean.validation.constraints.NotBlank; //导入依赖的package包/类
public static ConstraintSnippet getInstance(Constraint constraint) {
    if (constraint instanceof NotNull) {
        return new NotNullSnippet((NotNull) constraint);
    } else if (constraint instanceof Null) {
        return new NullSnippet((Null) constraint);
    } else if (constraint instanceof NotBlank) {
        return new NotBlankSnippet((NotBlank) constraint);
    } else if (constraint instanceof NotEmpty) {
        return new NotEmptySnippet((NotEmpty) constraint);
    } else if (constraint instanceof AssertFalse) {
        return new AssertFalseSnippet((AssertFalse) constraint);
    } else if (constraint instanceof AssertTrue) {
        return new AssertTrueSnippet((AssertTrue) constraint);
    } else if (constraint instanceof Past) {
        return new PastSnippet((Past) constraint);
    } else if (constraint instanceof PastOrPresent) {
        return new PastOrPresentSnippet((PastOrPresent) constraint);
    } else if (constraint instanceof Future) {
        return new FutureSnippet((Future) constraint);
    } else if (constraint instanceof FutureOrPresent) {
        return new FutureOrPresentSnippet((FutureOrPresent) constraint);
    } else if (constraint instanceof Size) {
        return new SizeSnippet((Size) constraint);
    } else if (constraint instanceof Pattern) {
        return new PatternSnippet((Pattern) constraint);
    } else if (constraint instanceof Email) {
        return new EmailSnippet((Email) constraint);
    } else if (constraint instanceof DecimalMin) {
        return new DecimalMinSnippet((DecimalMin) constraint);
    } else if (constraint instanceof DecimalMax) {
        return new DecimalMaxSnippet((DecimalMax) constraint);
    } else if (constraint instanceof Min) {
        return new MinSnippet((Min) constraint);
    } else if (constraint instanceof Max) {
        return new MaxSnippet((Max) constraint);
    } else if (constraint instanceof Digits) {
        return new DigitsSnippet((Digits) constraint);
    } else if (constraint instanceof Negative) {
        return new NegativeSnippet((Negative) constraint);
    } else if (constraint instanceof NegativeOrZero) {
        return new NegativeOrZeroSnippet((NegativeOrZero) constraint);
    } else if (constraint instanceof Positive) {
        return new PositiveSnippet((Positive) constraint);
    } else if (constraint instanceof PositiveOrZero) {
        return new PositiveOrZeroSnippet((PositiveOrZero) constraint);
    }

    throw new IllegalStateException(constraint.getClass().getName() + " not found");

}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:51,代码来源:ConstraintSnippetFactory.java


注:本文中的org.netbeans.bean.validation.constraints.NotBlank类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。