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


Java ConstraintHelper类代码示例

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


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

示例1: testConstraintViolationExceptionParameter

import org.hibernate.validator.internal.metadata.core.ConstraintHelper; //导入依赖的package包/类
@Test
public void testConstraintViolationExceptionParameter() {
	final Wine bean = new Wine();
	final Set<ConstraintViolation<?>> violations = new LinkedHashSet<>();

	final ConstraintHelper helper = new ConstraintHelper();

	final ConstraintDescriptor<NotEmpty> notEmptyNameDescriptor = new ConstraintDescriptorImpl<>(helper, (Member) null,
			getAnnotation("name", NotEmpty.class), ElementType.FIELD);
	PathImpl path = PathImpl.createPathFromString("name");
	violations.add(ConstraintViolationImpl.<Wine> forParameterValidation("name-Empty", null, null, "interpolated", Wine.class, bean, new Object(),
			"value", path, notEmptyNameDescriptor, ElementType.PARAMETER, null, null));
	path.addParameterNode("parameter1", 0);

	final ConstraintViolationException violationException = Mockito.mock(ConstraintViolationException.class);
	Mockito.when(violationException.getConstraintViolations()).thenReturn(violations);

	final ValidationJsonException validationJsonException = new ValidationJsonException(violationException);
	Assert.assertFalse(validationJsonException.getErrors().isEmpty());
	Assert.assertEquals("{parameter1=[{rule=name-Empty}]}", validationJsonException.getErrors().toString());
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:22,代码来源:ValidationJsonExceptionTest.java

示例2: BeanMetaDataManager513

import org.hibernate.validator.internal.metadata.core.ConstraintHelper; //导入依赖的package包/类
/**
 * Creates a new {@code BeanMetaDataManager}.
 *
 * @param constraintHelper
 *            the constraint helper
 * @param executableHelper
 *            the executable helper
 * @param parameterNameProvider
 *            the parameter name provider
 * @param optionalMetaDataProviders
 *            optional meta data provider used on top of the annotation
 *            based provider
 */
public BeanMetaDataManager513(ConstraintHelper constraintHelper, ExecutableHelper executableHelper,
		ParameterNameProvider parameterNameProvider, List<MetaDataProvider> optionalMetaDataProviders) {
	super(constraintHelper, executableHelper, parameterNameProvider, optionalMetaDataProviders);
	this.constraintHelper = constraintHelper;
	this.metaDataProviders = newArrayList();
	this.metaDataProviders.addAll(optionalMetaDataProviders);
	this.executableHelper = executableHelper;

	this.beanMetaDataCache = new ConcurrentReferenceHashMap<Class<?>, BeanMetaData<?>>(DEFAULT_INITIAL_CAPACITY,
			DEFAULT_LOAD_FACTOR, DEFAULT_CONCURRENCY_LEVEL, SOFT, SOFT, EnumSet.of(IDENTITY_COMPARISONS));

	AnnotationProcessingOptions annotationProcessingOptions = getAnnotationProcessingOptionsFromNonDefaultProviders();
	AnnotationMetaDataProvider defaultProvider = new AnnotationMetaDataProvider(constraintHelper,
			parameterNameProvider, annotationProcessingOptions);
	this.metaDataProviders.add(defaultProvider);
}
 
开发者ID:bradwoo8621,项目名称:nest-old,代码行数:30,代码来源:BeanMetaDataManager513.java

示例3: testConstraintViolationException

import org.hibernate.validator.internal.metadata.core.ConstraintHelper; //导入依赖的package包/类
@Test
public void testConstraintViolationException() {
	final Wine bean = new Wine();
	final Set<ConstraintViolation<?>> violations = new LinkedHashSet<>();

	final ConstraintHelper helper = new ConstraintHelper();

	final ConstraintDescriptor<NotEmpty> notEmptyNameDescriptor = new ConstraintDescriptorImpl<>(helper, (Member) null,
			getAnnotation("name", NotEmpty.class), ElementType.FIELD);
	final ConstraintDescriptor<NotEmpty> notEmptyGrapesDescriptor = new ConstraintDescriptorImpl<>(helper, (Member) null,
			getAnnotation("grapes", NotEmpty.class), ElementType.FIELD);
	final ConstraintDescriptor<Length> lengthNameDescriptor = new ConstraintDescriptorImpl<>(helper, (Member) null,
			getAnnotation("name", Length.class), ElementType.FIELD);
	violations.add(ConstraintViolationImpl.<Wine> forBeanValidation("name-Empty", null, null, "interpolated", Wine.class, bean, new Object(),
			"value", PathImpl.createPathFromString("name"), notEmptyNameDescriptor, ElementType.FIELD, null));
	violations.add(ConstraintViolationImpl.<Wine> forBeanValidation("name-length", null, null, "interpolated", Wine.class, bean, new Object(),
			"value", PathImpl.createPathFromString("name"), lengthNameDescriptor, ElementType.FIELD, null));
	violations.add(ConstraintViolationImpl.<Wine> forBeanValidation("grapes-Empty", null, null, "interpolated", Wine.class, bean, new Object(),
			"value", PathImpl.createPathFromString("grapes"), notEmptyGrapesDescriptor, ElementType.FIELD, null));

	final ConstraintViolationException violationException = Mockito.mock(ConstraintViolationException.class);
	Mockito.when(violationException.getConstraintViolations()).thenReturn(violations);

	final ValidationJsonException validationJsonException = new ValidationJsonException(violationException);
	Assert.assertFalse(validationJsonException.getErrors().isEmpty());
	Assert.assertEquals("{name=[{rule=name-Empty}, {rule=name-length, parameters={min=0, max=50}}], grapes=[{rule=grapes-Empty}]}",
			validationJsonException.getErrors().toString());
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:29,代码来源:ValidationJsonExceptionTest.java

示例4: BuilderDelegate

import org.hibernate.validator.internal.metadata.core.ConstraintHelper; //导入依赖的package包/类
@SuppressWarnings("incomplete-switch")
public BuilderDelegate(Class<?> beanClass, ConstrainedElement constrainedElement,
		ConstraintHelper constraintHelper, ExecutableHelper executableHelper) {
	this.beanClass = beanClass;
	this.constraintHelper = constraintHelper;
	this.executableHelper = executableHelper;

	switch (constrainedElement.getKind()) {
	case FIELD:
		ConstrainedField constrainedField = (ConstrainedField) constrainedElement;
		propertyBuilder = new PropertyMetaData.Builder(beanClass, constrainedField, constraintHelper);
		break;
	case CONSTRUCTOR:
	case METHOD:
		ConstrainedExecutable constrainedExecutable = (ConstrainedExecutable) constrainedElement;
		methodBuilder = new ExecutableMetaData.Builder(beanClass, constrainedExecutable, constraintHelper,
				executableHelper);

		if (constrainedExecutable.isGetterMethod()) {
			propertyBuilder = new PropertyMetaData.Builder(beanClass, constrainedExecutable, constraintHelper);
		}
		break;
	case TYPE:
		ConstrainedType constrainedType = (ConstrainedType) constrainedElement;
		propertyBuilder = new PropertyMetaData.Builder(beanClass, constrainedType, constraintHelper);
		break;
	}
}
 
开发者ID:bradwoo8621,项目名称:nest-old,代码行数:29,代码来源:BeanMetaDataImpl513.java

示例5: getMessageTemplate

import org.hibernate.validator.internal.metadata.core.ConstraintHelper; //导入依赖的package包/类
@Override
public String getMessageTemplate() {
  return (String) this.getAttributes().get(ConstraintHelper.MESSAGE);
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:5,代码来源:ConstraintDescriptorImpl.java

示例6: getValidationAppliesTo

import org.hibernate.validator.internal.metadata.core.ConstraintHelper; //导入依赖的package包/类
@Override
public ConstraintTarget getValidationAppliesTo() {
  return (ConstraintTarget) this.attributes.get(ConstraintHelper.VALIDATION_APPLIES_TO);
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:5,代码来源:ConstraintDescriptorImpl.java

示例7: ValidatorFactoryImpl513

import org.hibernate.validator.internal.metadata.core.ConstraintHelper; //导入依赖的package包/类
public ValidatorFactoryImpl513(ConfigurationState configurationState) {
	this.messageInterpolator = configurationState.getMessageInterpolator();
	this.traversableResolver = configurationState.getTraversableResolver();
	this.parameterNameProvider = configurationState.getParameterNameProvider();
	this.beanMetaDataManagerMap = Collections
			.synchronizedMap(new IdentityHashMap<ParameterNameProvider, BeanMetaDataManager513>());
	this.constraintHelper = new ConstraintHelper();
	this.typeResolutionHelper = new TypeResolutionHelper();
	this.executableHelper = new ExecutableHelper(typeResolutionHelper);

	// HV-302; don't load XmlMappingParser if not necessary
	if (configurationState.getMappingStreams().isEmpty()) {
		this.xmlMetaDataProvider = null;
	} else {
		this.xmlMetaDataProvider = new XmlMetaDataProvider(constraintHelper, parameterNameProvider,
				configurationState.getMappingStreams());
	}

	Map<String, String> properties = configurationState.getProperties();

	boolean tmpFailFast = false;
	List<ValidatedValueUnwrapper<?>> tmpValidatedValueHandlers = newArrayList(5);
	Set<DefaultConstraintMapping> tmpConstraintMappings = newHashSet();

	if (configurationState instanceof ConfigurationImpl) {
		ConfigurationImpl hibernateSpecificConfig = (ConfigurationImpl) configurationState;

		if (hibernateSpecificConfig.getProgrammaticMappings().size() > 0) {
			tmpConstraintMappings.addAll(hibernateSpecificConfig.getProgrammaticMappings());
		}
		// check whether fail fast is programmatically enabled
		tmpFailFast = hibernateSpecificConfig.getFailFast();

		tmpValidatedValueHandlers.addAll(hibernateSpecificConfig.getValidatedValueHandlers());

	}
	this.constraintMappings = Collections.unmodifiableSet(tmpConstraintMappings);

	tmpFailFast = checkPropertiesForFailFast(properties, tmpFailFast);
	this.failFast = tmpFailFast;

	tmpValidatedValueHandlers.addAll(getPropertyConfiguredValidatedValueHandlers(properties));
	this.validatedValueHandlers = Collections.unmodifiableList(tmpValidatedValueHandlers);

	this.constraintValidatorManager = new ConstraintValidatorManager(
			configurationState.getConstraintValidatorFactory());
}
 
开发者ID:bradwoo8621,项目名称:nest-old,代码行数:48,代码来源:ValidatorFactoryImpl513.java

示例8: BeanMetaDataBuilder

import org.hibernate.validator.internal.metadata.core.ConstraintHelper; //导入依赖的package包/类
private BeanMetaDataBuilder(ConstraintHelper constraintHelper, ExecutableHelper executableHelper,
		Class<T> beanClass) {
	this.beanClass = beanClass;
	this.constraintHelper = constraintHelper;
	this.executableHelper = executableHelper;
}
 
开发者ID:bradwoo8621,项目名称:nest-old,代码行数:7,代码来源:BeanMetaDataImpl513.java

示例9: getInstance

import org.hibernate.validator.internal.metadata.core.ConstraintHelper; //导入依赖的package包/类
public static <T> BeanMetaDataBuilder<T> getInstance(ConstraintHelper constraintHelper,
		ExecutableHelper executableHelper, Class<T> beanClass) {
	return new BeanMetaDataBuilder<T>(constraintHelper, executableHelper, beanClass);
}
 
开发者ID:bradwoo8621,项目名称:nest-old,代码行数:5,代码来源:BeanMetaDataImpl513.java

示例10: ProgrammaticMetaDataProvider513

import org.hibernate.validator.internal.metadata.core.ConstraintHelper; //导入依赖的package包/类
public ProgrammaticMetaDataProvider513(ConstraintHelper constraintHelper,
		ParameterNameProvider parameterNameProvider, Set<DefaultConstraintMapping> constraintMappings) {
	super(constraintHelper, parameterNameProvider, constraintMappings);
}
 
开发者ID:bradwoo8621,项目名称:nest-old,代码行数:5,代码来源:ProgrammaticMetaDataProvider513.java


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