Java 类org.hibernate.validator.cfg.defs.NotNullDef 实例源码

项目:javase-study    文件:SysRoleValidator.java   
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysRole.class)
            .property("roleName", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .constraint(new NotNullDef())
            .constraint(new PatternDef().regexp("^(?!root$).+$").message(
                    "may not be root"))
            .property("roleCode", ElementType.FIELD)
            .constraint(new NotNullDef()).constraint(new SizeDef().max(32));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
项目:javase-study    文件:SysRouteUpdateValidator.java   
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysRoute.class)
            .property("routeId", ElementType.FIELD)
            .constraint(new NotNullDef())
            .property("name", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .property("url", ElementType.FIELD)
            .constraint(new SizeDef().max(128))
            .constraint(new PatternDef()
                    .regexp("(/:?[0-9a-zA-Z_]+)*")
                    .message("{msg.error.validation.routeUrl.pattern}"));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
项目:javase-study    文件:SysMenuValidator.java   
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysMenu.class)
            .property("menuName", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .constraint(new NotNullDef())
            .property("menuPath", ElementType.FIELD)
            .constraint(new SizeDef().max(128))
            .constraint(new PatternDef()
                    .regexp("(/:?[0-9a-zA-Z_]+)*")
                    .message("{msg.error.validation.routeUrl.pattern}"))
            .property("parentId", ElementType.FIELD)
            .constraint(new NotNullDef())
            .property("icon", ElementType.FIELD)
            .constraint(new SizeDef().max(32));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
项目:javase-study    文件:SysUserUpdateValidator.java   
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysUser.class)
            .property("userId", ElementType.FIELD)
            .constraint(new NotNullDef())
            .property("username", ElementType.FIELD)
            .constraint(new SizeDef().max(16).min(3))
            .constraint(new PatternDef().regexp("[a-zA-Z][0-9a-zA-Z_]*")
                    .message("{msg.error.validation.username.pattern}"))
            .property("password", ElementType.FIELD)
            .constraint(new SizeDef().max(16).min(6))
            .property("fullName", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .property("email", ElementType.FIELD).constraint(new EmailDef())
            .constraint(new SizeDef().max(64));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
项目:javase-study    文件:SysRoleUpdateValidator.java   
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping.type(SysRole.class).property("roleId", ElementType.FIELD)
            .constraint(new NotNullDef())
            .property("roleName", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .constraint(new PatternDef().regexp("^(?!root$).+$").message("may not be root"))
            .property("roleCode", ElementType.FIELD)

            .constraint(new SizeDef().max(32));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
项目:javase-study    文件:SysUserValidator.java   
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysUser.class)
            .property("username", ElementType.FIELD)
            .constraint(new NotNullDef())
            .constraint(new SizeDef().max(16).min(3))
            .constraint(new PatternDef().regexp("[a-zA-Z][0-9a-zA-Z_]*")
                    .message("{msg.error.validation.username.pattern}"))
            .property("password", ElementType.FIELD)
            .constraint(new SizeDef().max(16).min(6))
            .constraint(new NotNullDef())
            .property("fullName", ElementType.FIELD)
            .constraint(new NotNullDef()).constraint(new SizeDef().max(32))
            .property("email", ElementType.FIELD)
            .constraint(new SizeDef().max(64)).constraint(new EmailDef());
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
项目:javase-study    文件:PasswordValidator.java   
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping.type(ChangePasswordVo.class)
            .property("oldpassword", ElementType.FIELD)
            .constraint(new SizeDef().max(16).min(6))
            .constraint(new NotNullDef())
            .property("newpassword", ElementType.FIELD)
            .constraint(new SizeDef().max(16).min(6))
            .constraint(new NotNullDef())
            .property("retypepassword", ElementType.FIELD)
            .constraint(new SizeDef().max(16).min(6))
            .constraint(new NotNullDef());
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
项目:javase-study    文件:SysMenuUpdateValidator.java   
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysMenu.class)
            .property("menuId", ElementType.FIELD)
            .constraint(new NotNullDef())
            .property("menuName", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .property("menuPath", ElementType.FIELD)
            .constraint(new SizeDef().max(128))
            .constraint(new PatternDef()
                    .regexp("(/:?[0-9a-zA-Z_]+)*")
                    .message("{msg.error.validation.routeUrl.pattern}"))
            .property("icon", ElementType.FIELD)
            .constraint(new SizeDef().max(32));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
项目:javase-study    文件:SysRouteValidator.java   
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysRoute.class)
            .property("name", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .constraint(new NotNullDef())
            .property("url", ElementType.FIELD)
            .constraint(new NotNullDef())
            .constraint(new SizeDef().max(128))
            .constraint(new PatternDef()
                    .regexp("(/:?[0-9a-zA-Z_]+)*")
                    .message("{msg.error.validation.routeUrl.pattern}"));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
项目:javase-study    文件:SysJobUpdateValidator.java   
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping.type(SysJob.class).property("jobId", ElementType.FIELD)
            .constraint(new NotNullDef())
            .property("clazzName", ElementType.FIELD).constraint(new NullDef())
            .property("jobName", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .property("cron", ElementType.FIELD)
            .constraint(new SizeDef().max(32));
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
项目:javase-study    文件:SysJobValidator.java   
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysJob.class)
            .property("clazzName", ElementType.FIELD)
            .constraint(new NotNullDef())
            .constraint(new SizeDef().max(64))
            .constraint(new PatternDef().regexp("[a-zA-Z.]+")
                    .message("{msg.error.validation.className.pattern}"))
            .property("jobName", ElementType.FIELD)
            .constraint(new SizeDef().max(32)).constraint(new NotNullDef())
            .property("cron", ElementType.FIELD)
            .constraint(new SizeDef().max(32)).constraint(new NotNullDef());
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
项目:javase-study    文件:SysDictValidator.java   
@Override
public Validator createValidator() {
    HibernateValidatorConfiguration configuration = Validation.byProvider(
            HibernateValidator.class).configure();

    ConstraintMapping constraintMapping = configuration.createConstraintMapping();

    constraintMapping
            .type(SysDict.class)
            .property("dictCode", ElementType.FIELD)
            .constraint(new SizeDef().max(32))
            .constraint(new NotNullDef())
            .constraint(new PatternDef().regexp("[0-9a-zA-Z_]+").message(
                    "{msg.error.validation.dictCode.pattern}"))
            .property("dictName", ElementType.FIELD)
            .constraint(new SizeDef().max(32)).constraint(new NotNullDef());
    return configuration.addMapping(constraintMapping).buildValidatorFactory()
            .getValidator();
}
项目:open-Autoscaler    文件:BeanValidation.java   
public static HibernateValidatorConfiguration getPolicyTriggerRange(HibernateValidatorConfiguration config) {

         Map<String, Map<String, Map<String, Map<String, String>>>> mulit_range = Constants.getTriggerRangeByTriggerType();
         logger.debug("mulit trigger range: " + mulit_range.toString());
         for (String class_type : mulit_range.keySet()){
             Map<String, Map<String, Map<String, String>>> range = mulit_range.get(class_type);
             Class<?> class_obj=null;
             if (class_type.equals("trigger_Memory")) //only one metricType supported now
                 class_obj = PolicyTrigger.class;
             for (String key : range.keySet()) {
                 Map<String, Map<String, String>> value = range.get(key);
                 for(String value_key : value.keySet()){
                     Map<String, String> value_item = value.get(value_key);
                     ConstraintMapping mapping = config.createConstraintMapping();
                     if (value_key.endsWith("Min")){
                         mapping.type(class_obj).property(key, ElementType.FIELD).constraint( new MinDef().value(Integer.parseInt(value_item.get("value"))).message(value_item.get("message")));
                     }
                     else if(value_key.endsWith("Max")){
                         mapping.type(class_obj).property(key, ElementType.FIELD).constraint( new MaxDef().value(Integer.parseInt(value_item.get("value"))).message(value_item.get("message")));
                     }
                     else if(value_key.endsWith("NotNull")){
                         mapping.type(class_obj).property(key, ElementType.FIELD).constraint( new NotNullDef().message(value_item.get("message")));
                     }
                     config.addMapping( mapping );
                 }
             }
         }
         return config;
    }
项目:dremio-oss    文件:InputValidation.java   
/**
 * constraints for Sources
 */
private void configureSources() {
  constraints.type(SourceUI.class)
    .property("name", FIELD).constraint(new PatternDef().regexp("^[^.\"]+$").message("Source name can not contain periods or double quotes"));

  constraints.type(Host.class)
  .property("hostname", FIELD).constraint(new NotBlankDef())
  .property("port", FIELD).constraint(new NotNullDef());

  constraints.type(ElasticConfig.class)
  .property("host", FIELD).constraint(new NotEmptyDef());

  constraints.type(HdfsConfig.class)
  .property("hostname", FIELD).constraint(new NotBlankDef());

  constraints.type(MongoConfig.class)
  .property("host", FIELD).constraint(new NotEmptyDef())
  .property("useSsl", FIELD).constraint(new NotNullDef());

  constraints.type(MSSQLConfig.class)
  .property("hostname", FIELD).constraint(new NotBlankDef())
  .property("port", FIELD).constraint(new NotBlankDef());

  constraints.type(MySQLConfig.class)
  .property("hostname", FIELD).constraint(new NotBlankDef())
  .property("port", FIELD).constraint(new NotBlankDef());

  constraints.type(NASConfig.class)
  .property("path", FIELD).constraint(new NotBlankDef());

  constraints.type(OracleConfig.class)
  .property("hostname", FIELD).constraint(new NotBlankDef())
  .property("port", FIELD).constraint(new NotBlankDef())
  .property("username", FIELD).constraint(new NotBlankDef())
  .property("password", FIELD).constraint(new NotBlankDef())
  .property("instance", FIELD).constraint(new NotBlankDef());

  constraints.type(DB2Config.class)
  .property("hostname", FIELD).constraint(new NotBlankDef())
  .property("port", FIELD).constraint(new NotBlankDef())
  .property("databaseName", FIELD).constraint(new NotBlankDef());

  constraints.type(PostgresConfig.class)
  .property("hostname", FIELD).constraint(new NotBlankDef())
  .property("port", FIELD).constraint(new NotBlankDef())
  .property("databaseName", FIELD).constraint(new NotBlankDef());

  constraints.type(S3Config.class)
  .property("secure", FIELD).constraint(new NotNullDef());
  // TODO These fields are only required when there are no external buckets
  // .property("accessKey", FIELD).constraint(new NotBlankDef())
  // .property("accessSecret", FIELD).constraint(new NotBlankDef());

  constraints.type(Property.class)
  .property("name", FIELD).constraint(new NotBlankDef())
  .property("value", FIELD).constraint(new NotBlankDef());

}
项目:dremio-oss    文件:InputValidation.java   
private void configureTransforms() {
  constraints.type(TransformSort.class)
  .property("sortedColumnName", FIELD).constraint(new NotBlankDef());
  //  order

  constraints.type(TransformSorts.class)
  .property("columns", FIELD).constraint(new NotEmptyDef());

  constraints.type(TransformDrop.class)
  .property("droppedColumnName", FIELD).constraint(new NotBlankDef());

  constraints.type(TransformRename.class)
  .property("oldColumnName", FIELD).constraint(new NotBlankDef())
  .property("newColumnName", FIELD).constraint(new NotBlankDef());

  constraints.type(TransformAddCalculatedField.class)
  .property("newColumnName", FIELD).constraint(new NotBlankDef())
  .property("expression", FIELD).constraint(new NotBlankDef());

  constraints.type(TransformUpdateSQL.class)
  .property("sql", FIELD).constraint(new NotBlankDef());

  constraints.type(TransformField.class)
  .property("sourceColumnName", FIELD).constraint(new NotBlankDef())
  .property("fieldTransformation", FIELD).constraint(new NotNullDef());
  //    newColumnName
  //    dropSourceColumn

  constraints.type(FieldConvertTextToDate.class)
  .property("format", FIELD).constraint(new NotBlankDef());
  // optional but one of the date/time types:
  // .property("desiredType", FIELD).constraint(new ());

  constraints.type(TransformConvertToSingleType.class)
  .property("sourceColumnName", FIELD).constraint(new NotBlankDef())
  .property("newColumnName", FIELD).constraint(new NotBlankDef())
  .property("dropSourceColumn", FIELD).constraint(new NotNullDef())
  .property("desiredType", FIELD).constraint(new NotNullDef())
  .property("castWhenPossible", FIELD).constraint(new NotNullDef())
  .property("actionForNonMatchingValue", FIELD).constraint(new NotNullDef());
  //      defaultValue // optional

  constraints.type(TransformSplitByDataType.class)
  .property("sourceColumnName", FIELD).constraint(new NotBlankDef())
  .property("newColumnNamePrefix", FIELD).constraint(new NotBlankDef())
  .property("dropSourceColumn", FIELD).constraint(new NotNullDef())
  .property("selectedTypes", FIELD).constraint(new NotEmptyDef());

  constraints.type(TransformFilter.class)
  .property("sourceColumnName", FIELD).constraint(new NotBlankDef())
  .property("filter", FIELD).constraint(new NotNullDef());
  //      keepNull
  //        exclude

  constraints.type(Dimension.class)
  .property("column", FIELD).constraint(new NotBlankDef());

  constraints.type(Measure.class)
  .property("column", FIELD).constraint(new NotBlankDef())
  .property("type", FIELD).constraint(new NotNullDef());

  constraints.type(TransformGroupBy.class).constraint(new TransformGroupByConstraintDef());
}
项目:nest-old    文件:NotNullConvertor.java   
/**
 * (non-Javadoc)
 * 
 * @see com.github.nest.arcteryx.meta.beans.internal.validators.hibernate.convertors.AbstractHibernateConstraintConvertor#createConstraintDef(com.github.nest.arcteryx.meta.beans.IConstraint)
 */
@SuppressWarnings("rawtypes")
@Override
protected ConstraintDef createConstraintDef(NotNullConstraint constraint) {
    return new NotNullDef();
}