本文整理汇总了Java中org.hibernate.validator.internal.engine.path.PathImpl类的典型用法代码示例。如果您正苦于以下问题:Java PathImpl类的具体用法?Java PathImpl怎么用?Java PathImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PathImpl类属于org.hibernate.validator.internal.engine.path包,在下文中一共展示了PathImpl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: processValidationError
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
/**
* @param ex {@link ConstraintViolationException}
* @return Returns an object with a list of incorrect parameters.
*/
@ExceptionHandler(ConstraintViolationException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ValidationErrorDTO processValidationError(final ConstraintViolationException ex) {
final ValidationErrorDTO validationErrorDTO = new ValidationErrorDTO();
final Set<ConstraintViolation<?>> set = ex.getConstraintViolations();
for (Iterator<ConstraintViolation<?>> iterator = set.iterator();iterator.hasNext(); ) {
ConstraintViolation<?> next = iterator.next();
validationErrorDTO.getFieldErrors()
.add(new ErrorFieldDTO(((PathImpl)next.getPropertyPath()).getLeafNode().getName(),
next.getMessage()));
}
return validationErrorDTO;
}
开发者ID:JonkiPro,项目名称:REST-Web-Services,代码行数:22,代码来源:IncorrectParametersExceptionHandler.java
示例2: validate
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
/**
* Validate a bean of given declared class.
*
* @param bean
* the bean to validate.
* @param parameter
* the runtime annotations of this parameter.
* @param validationErrors
* the errors list to fill.
*/
private void validate(final Object bean, final Method method, final Parameter parameter, final int index,
final Set<ConstraintViolation<?>> validationErrors) {
if (bean == null) {
// Parameter is null, is it manually checked of managed by CXF for
// multipart?
// All non-body parameters are required by default
final PathImpl propertyPath = PathImpl.createPathFromString(method.getName());
propertyPath.addParameterNode(parameter.getName(), index);
validationErrors.add(ConstraintViolationImpl.forParameterValidation(NotNull.class.getName(), null, null, "interpolated", null,
null, null, null, propertyPath, NOT_NULL_DESCRIPTOR, null, null, null));
return;
}
final Class<?> clazz = bean.getClass();
if (Collection.class.isAssignableFrom(clazz)) {
validate((Collection<?>) bean, validationErrors);
} else if (clazz.isArray()) {
validate((Object[]) bean, validationErrors);
} else {
validateSimpleBean(bean, validationErrors);
}
}
开发者ID:ligoj,项目名称:bootstrap,代码行数:34,代码来源:JAXRSBeanValidationImplicitInInterceptor.java
示例3: testConstraintViolationExceptionParameter
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的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
示例4: getPropertyPath
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
/**
* Return the property path from the given validation error.
*/
private String getPropertyPath(final ConstraintViolation<?> error) {
if (((PathImpl) error.getPropertyPath()).getLeafNode().getKind() == ElementKind.PARAMETER) {
// JSR-349 - Parameter, drop parent context
return ((PathImpl) error.getPropertyPath()).getLeafNode().getName();
}
// JSR-303 - Bean violation
return error.getPropertyPath().toString();
}
开发者ID:ligoj,项目名称:bootstrap,代码行数:12,代码来源:ValidationJsonException.java
示例5: testConstraintViolationException
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的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
示例6: addValidationError
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
/**
* Utility method for adding error of ConstraintViolation. Usually when a @Validated validation fails.
*
* @param cv the ConstraintViolation
*/
private void addValidationError(ConstraintViolation<?> cv) {
this.addValidationError(
cv.getRootBeanClass().getSimpleName(),
((PathImpl) cv.getPropertyPath()).getLeafNode().asString(),
cv.getInvalidValue(),
cv.getMessage());
}
开发者ID:h819,项目名称:spring-boot,代码行数:13,代码来源:RestApiError.java
示例7: NodeBuilderCustomizableContextImpl
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
/**
* constructor.
*
* @param parent ConstraintViolationBuilderImpl which is parent
* @param messageTemplate message template
* @param path path of the element
*/
public NodeBuilderCustomizableContextImpl(final ConstraintViolationBuilderImpl parent,
final String messageTemplate, final PathImpl path) {
super();
this.parent = parent;
this.messageTemplate = messageTemplate;
this.path = path;
}
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:15,代码来源:ConstraintValidatorContextImpl.java
示例8: NodeContextBuilderImpl
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
/**
* constructor.
*
* @param parent ConstraintViolationBuilderImpl which is parent
* @param messageTemplate message template
* @param path path of the element
*/
public NodeContextBuilderImpl(final PathImpl path, final String messageTemplate,
final ConstraintViolationBuilderImpl parent) {
super();
this.path = path;
this.messageTemplate = messageTemplate;
this.parent = parent;
}
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:15,代码来源:ConstraintValidatorContextImpl.java
示例9: ConstraintValidatorContextImpl
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
/**
* constructor.
*
* @param path path of the element
* @param descriptor constraint descriptor
*/
public ConstraintValidatorContextImpl(final PathImpl path,
final ConstraintDescriptor<A> descriptor) {
super();
this.basePath = path;
this.descriptor = descriptor;
}
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:13,代码来源:ConstraintValidatorContextImpl.java
示例10: append
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
/**
* Append a node named name to the path..
*
* @return the new GwtValidationContext.
*/
public GwtValidationContext<T> append(final String name) {
final GwtValidationContext<T> temp = new GwtValidationContext<>(this.rootBeanClass,
this.rootBean, this.beanDescriptor, this.messageInterpolator, this.traversableResolver,
this.validator, this.validatedObjects);
temp.path = PathImpl.createCopy(this.path);
temp.path.addPropertyNode(name);
return temp;
}
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:14,代码来源:GwtValidationContext.java
示例11: appendIndex
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
/**
* Append an indexed node to the path.
*
* @return the new GwtValidationContext.
*/
public GwtValidationContext<T> appendIndex(final String name, final int index) {
final GwtValidationContext<T> temp = new GwtValidationContext<>(this.rootBeanClass,
this.rootBean, this.beanDescriptor, this.messageInterpolator, this.traversableResolver,
this.validator, this.validatedObjects);
temp.path = PathImpl.createCopy(this.path);
temp.path.addParameterNode(name, index);
temp.path.makeLeafNodeIterable();
temp.path.makeLeafNodeIterableAndSetIndex(index);
return temp;
}
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:16,代码来源:GwtValidationContext.java
示例12: appendIterable
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
/**
* Append an iterable node to the path.
*
* @return the new GwtValidationContext.
*/
public GwtValidationContext<T> appendIterable(final String name) {
final GwtValidationContext<T> temp = new GwtValidationContext<>(this.rootBeanClass,
this.rootBean, this.beanDescriptor, this.messageInterpolator, this.traversableResolver,
this.validator, this.validatedObjects);
temp.path = PathImpl.createCopy(this.path);
temp.path.addPropertyNode(name);
temp.path.makeLeafNodeIterable();
return temp;
}
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:15,代码来源:GwtValidationContext.java
示例13: appendKey
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
/**
* Append a keyed node to the path.
*
* @return the new GwtValidationContext.
*/
public GwtValidationContext<T> appendKey(final String name, final Object key) {
final GwtValidationContext<T> temp = new GwtValidationContext<>(this.rootBeanClass,
this.rootBean, this.beanDescriptor, this.messageInterpolator, this.traversableResolver,
this.validator, this.validatedObjects);
temp.path = PathImpl.createCopy(this.path);
temp.path.addPropertyNode(name);
NodeImpl.makeIterableAndSetMapKey(temp.path.getLeafNode(), key);
return temp;
}
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:15,代码来源:GwtValidationContext.java
示例14: ConstraintViolationCreationContext
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
/**
* constructor.
*/
public ConstraintViolationCreationContext(final String message, final PathImpl property,
final Map<String, Object> messageParameters, final Map<String, Object> expressionVariables,
final Object dynamicPayload) {
this.message = message;
this.propertyPath = property;
this.messageParameters = toImmutableMap(messageParameters);
this.expressionVariables = toImmutableMap(expressionVariables);
this.dynamicPayload = dynamicPayload;
}
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:13,代码来源:ConstraintViolationCreationContext.java
示例15: compose
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
@Override
protected void compose(final ClassSourceFileComposerFactory composerFactory) {
this.addImports(composerFactory, Annotation.class, ConstraintViolation.class, GWT.class,
ValidationGroupsMetadata.class, Group.class, GroupChain.class, PathImpl.class, Node.class,
GroupChainGenerator.class, GwtBeanDescriptor.class, BeanMetadata.class,
GwtValidationContext.class, ArrayList.class, HashSet.class, IllegalArgumentException.class,
Set.class, Collection.class, Iterator.class, List.class, ValidationException.class);
composerFactory.setSuperclass(AbstractGwtSpecificValidator.class.getCanonicalName() + "<"
+ this.beanType.getQualifiedSourceName() + ">");
composerFactory.addImplementedInterface(this.validatorType.getName());
}
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:12,代码来源:GwtSpecificValidatorCreator.java
示例16: getConstraintViolationBuilder
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
ConstraintViolationBuilder getConstraintViolationBuilder() {
return new ConstraintValidatorContextImpl(
Collections.emptyList(), null,
PathImpl.createRootPath(),
new DummyConstraintDescriptor()
).buildConstraintViolationWithTemplate("dummytemplate");
}
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:8,代码来源:AbstractValidatorTest.java
示例17: setUp
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
@Before
public void setUp() {
underTest = new UpdateStackRequestValidator();
constraintValidatorContext = new ConstraintValidatorContextImpl(
new ArrayList<>(), null,
PathImpl.createRootPath(),
new DummyConstraintDescriptor()
);
}
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:10,代码来源:UpdateStackRequestValidatorTest.java
示例18: getPropertyPath
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
@Override
public Path getPropertyPath() {
return PathImpl.createPathFromString(propertyPath);
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:5,代码来源:MockConstraintViolation.java
示例19: setup
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
@Before
public void setup() {
validator = new PointLocationValidator();
context = new ConstraintValidatorContextImpl(null, null, PathImpl.createPathFromString("WOW"), null);
}
开发者ID:NWQMC,项目名称:WQP-WQX-Services,代码行数:6,代码来源:PointLocationValidatorTest.java
示例20: addValidationError
import org.hibernate.validator.internal.engine.path.PathImpl; //导入依赖的package包/类
/**
* Utility method for adding error of ConstraintViolation. Usually when a @Validated
* validation fails.
* @param cv the ConstraintViolation
*/
private void addValidationError(ConstraintViolation<?> cv) {
this.addValidationError(cv.getRootBeanClass().getSimpleName(),
((PathImpl) cv.getPropertyPath()).getLeafNode().asString(),
cv.getInvalidValue(), cv.getMessage());
}
开发者ID:rajadilipkolli,项目名称:POC,代码行数:11,代码来源:ApiError.java
注:本文中的org.hibernate.validator.internal.engine.path.PathImpl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论