V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  abokchoy  ›  全部回复第 1 页 / 共 1 页
回复总数  3
261 天前
回复了 abokchoy 创建的主题 程序员 Java 求助
@gitdoit 多谢多谢
262 天前
回复了 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);
}

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