|
@@ -20,16 +20,16 @@ public class ObjectUtils {
|
|
private static final String NULL = "null";
|
|
private static final String NULL = "null";
|
|
private static final String UNDEFINED = "undefined";
|
|
private static final String UNDEFINED = "undefined";
|
|
|
|
|
|
- public static <T> Collection<T> requireNonNull(Collection<T> input, String... errorMsg){
|
|
|
|
|
|
+ public static <T> Collection<T> requireNonNull(Collection<T> input, String errorMsg){
|
|
if (null == input || input.size() == 0) {
|
|
if (null == input || input.size() == 0) {
|
|
- throw new IllegalArgumentException(errorMsg[0]);
|
|
|
|
|
|
+ throw new IllegalArgumentException(errorMsg);
|
|
}
|
|
}
|
|
return input;
|
|
return input;
|
|
}
|
|
}
|
|
|
|
|
|
- public static <T> List<T> requireNonNull(List<T> input, String... errorMsg){
|
|
|
|
|
|
+ public static <T> List<T> requireNonNull(List<T> input, String errorMsg){
|
|
if (null == input || input.size() == 0) {
|
|
if (null == input || input.size() == 0) {
|
|
- throw new IllegalArgumentException(errorMsg[0]);
|
|
|
|
|
|
+ throw new IllegalArgumentException(errorMsg);
|
|
}
|
|
}
|
|
return input;
|
|
return input;
|
|
}
|
|
}
|
|
@@ -42,40 +42,40 @@ public class ObjectUtils {
|
|
return !isEmpty(input);
|
|
return !isEmpty(input);
|
|
}
|
|
}
|
|
|
|
|
|
- public static long[] requireNonNull(long[] input, String... errorMsg){
|
|
|
|
|
|
+ public static long[] requireNonNull(long[] input, String errorMsg){
|
|
if (ArrayUtils.isEmpty(input)) {
|
|
if (ArrayUtils.isEmpty(input)) {
|
|
- throw new IllegalArgumentException(errorMsg[0]);
|
|
|
|
|
|
+ throw new IllegalArgumentException(errorMsg);
|
|
}
|
|
}
|
|
|
|
|
|
return input;
|
|
return input;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public static Long[] requireNonNull(Long[] input, String... errorMsg){
|
|
|
|
|
|
+ public static Long[] requireNonNull(Long[] input, String errorMsg){
|
|
if (ArrayUtils.isEmpty(input)) {
|
|
if (ArrayUtils.isEmpty(input)) {
|
|
- throw new IllegalArgumentException(errorMsg[0]);
|
|
|
|
|
|
+ throw new IllegalArgumentException(errorMsg);
|
|
}
|
|
}
|
|
|
|
|
|
return input;
|
|
return input;
|
|
}
|
|
}
|
|
|
|
|
|
- public static Boolean requireNonNull(Boolean input, String... errorMsg) {
|
|
|
|
|
|
+ public static Boolean requireNonNull(Boolean input, String errorMsg) {
|
|
if (input == null) {
|
|
if (input == null) {
|
|
- throw new IllegalArgumentException(errorMsg[0]);
|
|
|
|
|
|
+ throw new IllegalArgumentException(errorMsg);
|
|
}
|
|
}
|
|
return input;
|
|
return input;
|
|
}
|
|
}
|
|
|
|
|
|
- public static <T> T requireNonNull(T input, String... errorMsg) {
|
|
|
|
|
|
+ public static <T> T requireNonNull(T input, String errorMsg) {
|
|
if (input == null) {
|
|
if (input == null) {
|
|
- throw new IllegalArgumentException(errorMsg[0]);
|
|
|
|
|
|
+ throw new IllegalArgumentException(errorMsg);
|
|
}
|
|
}
|
|
return input;
|
|
return input;
|
|
}
|
|
}
|
|
|
|
|
|
- public static Integer requireNonNull(Integer input, String... errorMsg) {
|
|
|
|
|
|
+ public static Integer requireNonNull(Integer input, String errorMsg) {
|
|
if (input == null || input < 0) {
|
|
if (input == null || input < 0) {
|
|
- throw new IllegalArgumentException(errorMsg[0]);
|
|
|
|
|
|
+ throw new IllegalArgumentException(errorMsg);
|
|
}
|
|
}
|
|
return input;
|
|
return input;
|
|
}
|
|
}
|
|
@@ -97,24 +97,24 @@ public class ObjectUtils {
|
|
return !isEmpty(input);
|
|
return !isEmpty(input);
|
|
}
|
|
}
|
|
|
|
|
|
- public static String requireNonNull(String input, String... errorMsg) {
|
|
|
|
|
|
+ public static String requireNonNull(String input, String errorMsg) {
|
|
if (input == null || input.isEmpty() || NULL.equalsIgnoreCase(input) || UNDEFINED.equalsIgnoreCase(input)) {
|
|
if (input == null || input.isEmpty() || NULL.equalsIgnoreCase(input) || UNDEFINED.equalsIgnoreCase(input)) {
|
|
- throw new IllegalArgumentException(errorMsg[0]);
|
|
|
|
|
|
+ throw new IllegalArgumentException(errorMsg);
|
|
}
|
|
}
|
|
return input;
|
|
return input;
|
|
}
|
|
}
|
|
|
|
|
|
- public static int requireNonNull(int input, String... errorMsg) {
|
|
|
|
|
|
+ public static int requireNonNull(int input, String errorMsg) {
|
|
if (input <= 0) {
|
|
if (input <= 0) {
|
|
- throw new IllegalArgumentException(errorMsg[0]);
|
|
|
|
|
|
+ throw new IllegalArgumentException(errorMsg);
|
|
}
|
|
}
|
|
return input;
|
|
return input;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public static JSONObject requireNonNull(JSONObject input, String... errorMsg) {
|
|
|
|
|
|
+ public static JSONObject requireNonNull(JSONObject input, String errorMsg) {
|
|
if (input == null || input.isEmpty()) {
|
|
if (input == null || input.isEmpty()) {
|
|
- throw new IllegalArgumentException(errorMsg[0]);
|
|
|
|
|
|
+ throw new IllegalArgumentException(errorMsg);
|
|
}
|
|
}
|
|
return input;
|
|
return input;
|
|
}
|
|
}
|
|
@@ -187,9 +187,9 @@ public class ObjectUtils {
|
|
return !isEmpty(input);
|
|
return !isEmpty(input);
|
|
}
|
|
}
|
|
|
|
|
|
- public static JSONArray requireNonNull(JSONArray input, String... errorMsg) {
|
|
|
|
|
|
+ public static JSONArray requireNonNull(JSONArray input, String errorMsg) {
|
|
if (input == null || input.isEmpty()) {
|
|
if (input == null || input.isEmpty()) {
|
|
- throw new IllegalArgumentException(errorMsg[0]);
|
|
|
|
|
|
+ throw new IllegalArgumentException(errorMsg);
|
|
}
|
|
}
|
|
return input;
|
|
return input;
|
|
}
|
|
}
|