• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ConstraintMapping类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createValidator

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:20,代码来源:SysRoleValidator.java


示例2: createValidator

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:22,代码来源:SysRouteUpdateValidator.java


示例3: createValidator

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:25,代码来源:SysMenuValidator.java


示例4: createValidator

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:25,代码来源:SysUserUpdateValidator.java


示例5: createValidator

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:19,代码来源:SysRoleUpdateValidator.java


示例6: createValidator

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:25,代码来源:SysUserValidator.java


示例7: createValidator

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:21,代码来源:PasswordValidator.java


示例8: createValidator

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:24,代码来源:SysMenuUpdateValidator.java


示例9: createValidator

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:22,代码来源:SysRouteValidator.java


示例10: createValidator

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:18,代码来源:SysJobUpdateValidator.java


示例11: createValidator

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:22,代码来源:SysJobValidator.java


示例12: createValidator

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@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();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:20,代码来源:SysDictValidator.java


示例13: postProcessConfiguration

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@Override
protected void postProcessConfiguration(Configuration<?> configuration) {
    super.postProcessConfiguration(configuration);
    HibernateValidatorConfiguration hibernateConfiguration = (HibernateValidatorConfiguration) configuration;

    ConstraintMapping constraintMapping = hibernateConfiguration.createConstraintMapping();
    validators.forEach(validator -> addConstraint(constraintMapping, validator));
    hibernateConfiguration.addMapping(constraintMapping);

    hibernateValidatorConfigurationStrategy.accept(hibernateConfiguration);
}
 
开发者ID:infobip,项目名称:infobip-bean-validation,代码行数:12,代码来源:CustomLocalValidatorFactoryBean.java


示例14: addConstraint

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
private void addConstraint(ConstraintMapping mapping, ConstraintValidator validator) {
    Stream.of(validator.getClass().getGenericInterfaces())
          .filter(genericInterface -> genericInterface instanceof ParameterizedType)
          .map(genericInterface -> (ParameterizedType) genericInterface)
          .filter(genericInterface -> isConstraintValidator(genericInterface.getRawType()))
          .forEach(constraintValidatorInterface -> {
              @SuppressWarnings("unchecked")
              Class<? extends Annotation> a = (Class<? extends Annotation>) constraintValidatorInterface.getActualTypeArguments()[0];
              mapping.constraintDefinition(a).validatedBy(getValidatorClass(validator));
          });
}
 
开发者ID:infobip,项目名称:infobip-bean-validation,代码行数:12,代码来源:CustomLocalValidatorFactoryBean.java


示例15: getPolicyTriggerRange

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
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;
	}
 
开发者ID:cfibmers,项目名称:open-Autoscaler,代码行数:30,代码来源:BeanValidation.java


示例16: getValidator

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@Override
public Validator getValidator(@Nullable ConstraintMapping constraintMapping, ValidationOptions options) {
    checkNotNullArgument(options);

    if (constraintMapping == null
            && options.getFailFast() == null
            && options.getLocale() != null) {
        return getValidatorWithDefaultFactory(options.getLocale());
    }

    Locale locale;
    if (options.getLocale() != null) {
        locale = options.getLocale();
    } else {
        locale = getCurrentLocale();
    }

    HibernateValidatorConfiguration configuration = getValidatorFactoryConfiguration(locale);
    if (options.getFailFast() != null) {
        configuration.failFast(options.getFailFast());
    }
    if (constraintMapping != null) {
        configuration.addMapping(constraintMapping);
    }

    ValidatorFactory factory = configuration.buildValidatorFactory();
    return factory.getValidator();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:29,代码来源:BeanValidationImpl.java


示例17: initialize

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
/**
 * initialize constraints of bean descriptor
 * 
 * @param descriptor
 */
@SuppressWarnings("rawtypes")
protected void initialize(IBeanDescriptor descriptor) {
	if (logger.isDebugEnabled()) {
		logger.debug("Initialize bean descriptor [" + descriptor + "].");
	}
	ConstraintMapping mapping = getConfiguration().createConstraintMapping();
	TypeConstraintMappingContext context = mapping.type(descriptor.getBeanClass());

	this.generateTypeLevelConstraints(descriptor, context);
	this.generatePropertyLevelConstraints(descriptor, context);

	getConfiguration().addMapping(mapping);
}
 
开发者ID:bradwoo8621,项目名称:nest-old,代码行数:19,代码来源:HibernateValidationConfigurationInitializer.java


示例18: getValidator

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@Override
public Validator getValidator(ConstraintMapping constraintMapping) {
    return new ValidatorStub();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:5,代码来源:TestBeanValidation.java


示例19: run

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
@Override
@Context
public void run(OdsConfig configuration, Environment environment) {
	Injector injector = Guice.createInjector(
			new MonitoringModule(environment.metrics()),
			new ConfigModule(configuration),
			new ProcessorModule(),
			new DbModule(configuration.getCouchDb()),
			new NotificationsModule(),
			new DataModule(),
			new AuthModule(configuration.getAuth()));

	// start data grabbing
	environment.lifecycle().manage(injector.getInstance(DataSourceManager.class));
	environment.jersey().getResourceConfig().register(MultiPartFeature.class);
	environment.jersey().getResourceConfig().register(injector.getInstance(AuthBinder.class));
	environment.jersey().register(injector.getInstance(DataSourceApi.class));
	environment.jersey().register(injector.getInstance(DataApi.class));
	environment.jersey().register(injector.getInstance(ProcessorChainApi.class));
	environment.jersey().register(injector.getInstance(DataViewApi.class));
	environment.jersey().register(injector.getInstance(NotificationApi.class));
	environment.jersey().register(injector.getInstance(PluginApi.class));
	environment.jersey().register(injector.getInstance(ProcessorSpecificationApi.class));
	environment.jersey().register(injector.getInstance(VersionApi.class));
	environment.jersey().register(injector.getInstance(UserApi.class));
	environment.jersey().register(PropertyFilteringMessageBodyWriter.class);
	environment.jersey().register(new DbExceptionMapper());
	environment.jersey().register(new JsonExceptionMapper());
	environment.jersey().register(new UnauthorizedExceptionMapper());
	environment.jersey().register(new NotFoundExceptionMapper());

	// setup users
	setupDefaultUsers(injector.getInstance(UserManager.class), configuration.getAuth().getUsers());

	// setup health checks
	environment.healthChecks().register(DbHealthCheck.class.getSimpleName(), injector.getInstance(DbHealthCheck.class));
	environment.healthChecks().register(PegelOnlineHealthCheck.class.getSimpleName(), injector.getInstance(PegelOnlineHealthCheck.class));
	environment.healthChecks().register(DataSourceHealthCheck.class.getSimpleName(), injector.getInstance(DataSourceHealthCheck.class));
	environment.healthChecks().register(FilterChainHealthCheck.class.getSimpleName(), injector.getInstance(FilterChainHealthCheck.class));
	environment.healthChecks().register(DataHealthCheck.class.getSimpleName(), injector.getInstance(DataHealthCheck.class));
	environment.healthChecks().register(CepsClientHealthCheck.class.getSimpleName(), injector.getInstance(CepsClientHealthCheck.class));

	// configure administration
	DropwizardResourceConfig jerseyConfig = new DropwizardResourceConfig(environment.metrics());
	JerseyContainerHolder jerseyContainerHolder = new JerseyContainerHolder(new ServletContainer(jerseyConfig));
	jerseyConfig.register(injector.getInstance(AdminFilterChainApi.class));
	environment.admin().addServlet("admin resources", jerseyContainerHolder.getContainer()).addMapping("/admin/*");

	// setup validation for external classes
	HibernateValidatorConfiguration validatorContext = Validation.byProvider(HibernateValidator.class).configure();
	ConstraintMapping mapping = validatorContext.createConstraintMapping();
	mapping.type(ProcessorReferenceChainDescription.class).constraint(new GenericConstraintDef<>(ValidChainReference.class));

	// setup Guice DI for hibernate validator
	environment.setValidator(validatorContext.addMapping(mapping)
			.constraintValidatorFactory(new GuiceConstraintValidatorFactory(injector))
			.buildValidatorFactory()
			.getValidator());
}
 
开发者ID:jvalue,项目名称:open-data-service,代码行数:60,代码来源:OdsApplication.java


示例20: getValidator

import org.hibernate.validator.cfg.ConstraintMapping; //导入依赖的package包/类
/**
 * Get validator with custom constraint mapping and current locale if there is current UserSession or with default locale.
 *
 * @param constraintMapping constraint mapping
 * @return validator
 */
Validator getValidator(ConstraintMapping constraintMapping);
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:8,代码来源:BeanValidation.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IASTEnumerator类代码示例发布时间:2022-05-23
下一篇:
Java KeyboardShortcutGroup类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap