重构收藏模块.
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package com.orion.ops.framework.common.utils;
|
||||
|
||||
import com.orion.lang.utils.Arrays1;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.spring.SpringHolder;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.Validator;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -20,6 +22,58 @@ public class Valid extends com.orion.lang.utils.Valid {
|
||||
|
||||
private static final Validator VALIDATOR = SpringHolder.getBean(Validator.class);
|
||||
|
||||
public static <T> T notNull(T object) {
|
||||
return notNull(object, ErrorMessage.PARAM_MISSING);
|
||||
}
|
||||
|
||||
public static String notBlank(String s) {
|
||||
return notBlank(s, ErrorMessage.PARAM_MISSING);
|
||||
}
|
||||
|
||||
public static <T extends Collection<?>> T notEmpty(T object) {
|
||||
return notEmpty(object, ErrorMessage.PARAM_MISSING);
|
||||
}
|
||||
|
||||
public static void allNotNull(Object... objects) {
|
||||
if (objects != null) {
|
||||
for (Object t : objects) {
|
||||
notNull(t, ErrorMessage.PARAM_MISSING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void allNotBlank(String... ss) {
|
||||
if (ss != null) {
|
||||
for (String s : ss) {
|
||||
notBlank(s, ErrorMessage.PARAM_MISSING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void eq(Object o1, Object o2) {
|
||||
eq(o1, o2, ErrorMessage.INVALID_PARAM);
|
||||
}
|
||||
|
||||
public static boolean isTrue(boolean s) {
|
||||
return isTrue(s, ErrorMessage.INVALID_PARAM);
|
||||
}
|
||||
|
||||
public static boolean isFalse(boolean s) {
|
||||
return isFalse(s, ErrorMessage.INVALID_PARAM);
|
||||
}
|
||||
|
||||
public static <T extends Comparable<T>> T gte(T t1, T t2) {
|
||||
return gte(t1, t2, ErrorMessage.INVALID_PARAM);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static <T> T in(T t, T... ts) {
|
||||
notNull(t, ErrorMessage.INVALID_PARAM);
|
||||
notEmpty(ts, ErrorMessage.INVALID_PARAM);
|
||||
isTrue(Arrays1.contains(ts, t), ErrorMessage.INVALID_PARAM);
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证枚举
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user