當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。