BeanDefinitionDtoConverterServiceImpl.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:geomajas-project-server 作者:
/**
 * Take a stab at fixing validation problems ?
 * 
 * @param object
 */
private void validate(Object object) {
    Set<ConstraintViolation<Object>> viols = validator.validate(object);
    for (ConstraintViolation<Object> constraintViolation : viols) {
        if (Null.class.isAssignableFrom(constraintViolation.getConstraintDescriptor().getAnnotation().getClass())) {
            Object o = constraintViolation.getLeafBean();
            Iterator<Node> iterator = constraintViolation.getPropertyPath().iterator();
            String propertyName = null;
            while (iterator.hasNext()) {
                propertyName = iterator.next().getName();
            }
            if (propertyName != null) {
                try {
                    PropertyDescriptor descriptor = BeanUtils.getPropertyDescriptor(o.getClass(), propertyName);
                    descriptor.getWriteMethod().invoke(o, new Object[] { null });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号