|
@@ -19,6 +19,7 @@
|
|
|
package org.hswebframework.web.api.crud.entity;
|
|
|
|
|
|
|
|
|
+import org.hswebframework.ezorm.core.StaticMethodReferenceColumn;
|
|
|
import org.hswebframework.web.bean.FastBeanCopier;
|
|
|
import org.hswebframework.web.validator.ValidatorUtils;
|
|
|
|
|
@@ -42,6 +43,26 @@ public interface Entity extends Serializable {
|
|
|
ValidatorUtils.tryValidate(this, groups);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 使用jsr303对当前实体类的指定属性进行验证,如果未通过验证则会抛出{@link org.hswebframework.web.exception.ValidationException}异常
|
|
|
+ *
|
|
|
+ * @param groups 分组
|
|
|
+ * @see org.hswebframework.web.exception.ValidationException
|
|
|
+ */
|
|
|
+ default void tryValidate(String property, Class<?>... groups) {
|
|
|
+ ValidatorUtils.tryValidate(this, property, groups);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 使用jsr303对当前实体类的指定属性进行验证,如果未通过验证则会抛出{@link org.hswebframework.web.exception.ValidationException}异常
|
|
|
+ *
|
|
|
+ * @param groups 分组
|
|
|
+ * @see org.hswebframework.web.exception.ValidationException
|
|
|
+ */
|
|
|
+ default void tryValidate(StaticMethodReferenceColumn<?> property, Class<?>... groups) {
|
|
|
+ tryValidate(property.getColumn(), groups);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 将当前实体类复制到指定其他类型中,类型将会被自动实例化,在类型明确时,建议使用{@link Entity#copyFrom(Object, String...)}.
|
|
|
*
|