V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  abokchoy  ›  全部回复第 1 页 / 共 1 页
回复总数  3
265 天前
回复了 abokchoy 创建的主题 程序员 Java 求助
@gitdoit 多谢多谢
265 天前
回复了 abokchoy 创建的主题 程序员 Java 求助
```java
public final <T> Set<ConstraintViolation<T>> validate(T object, Class<?>... groups) {
Contracts.assertNotNull(object, Messages.MESSAGES.validatedObjectMustNotBeNull());
ValidationContext<T> validationContext = this.getValidationContextBuilder().forValidate(object);
if (!validationContext.getRootBeanMetaData().hasConstraints()) {
return Collections.emptySet();
} else {
ValidationOrder validationOrder = this.determineGroupValidationOrder(groups);
ValueContext<?, Object> valueContext = ValueContext.getLocalExecutionContext(this.parameterNameProvider, object, validationContext.getRootBeanMetaData(), PathImpl.createRootPath());
return this.validateInContext(validationContext, valueContext, validationOrder);
}
}

public <T> ValidationContext<T> forValidate(T rootBean) {
Class<T> rootBeanClass = rootBean.getClass();
return new ValidationContext(this.constraintValidatorManager, this.messageInterpolator, this.constraintValidatorFactory, this.traversableResolver, (ExecutableParameterNameProvider)null, this.clockProvider, this.failFast, rootBean, rootBeanClass, this.beanMetaDataManager.getBeanMetaData(rootBeanClass), (Executable)null, (Object[])null, (Object)null);
}

```
反射拿了对象的类信息
265 天前
回复了 abokchoy 创建的主题 程序员 Java 求助
@Belmode 试了,不行
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   6044 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 02:27 · PVG 10:27 · LAX 18:27 · JFK 21:27
Developed with CodeLauncher
♥ Do have faith in what you're doing.