You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.2 KiB
Java
60 lines
1.2 KiB
Java
package com.glxp.api.util;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
public class IntUtil {
|
|
|
|
public static int value(Integer value) {
|
|
if (value == null)
|
|
return 0;
|
|
else return value.intValue();
|
|
|
|
}
|
|
|
|
public static BigDecimal value(BigDecimal value) {
|
|
if (value == null)
|
|
return new BigDecimal(0);
|
|
else return value;
|
|
|
|
}
|
|
|
|
|
|
public static long value(Long value) {
|
|
if (value == null)
|
|
return 0l;
|
|
else return value.longValue();
|
|
|
|
}
|
|
|
|
|
|
public static boolean value(Boolean value) {
|
|
if (value == null)
|
|
return false;
|
|
else return value;
|
|
}
|
|
|
|
public static int value(String value) {
|
|
if (StrUtil.isEmpty(value))
|
|
return 0;
|
|
else return Integer.parseInt(value);
|
|
|
|
}
|
|
|
|
|
|
public static int value(Integer value, int defaultValue) {
|
|
if (value != null && value != 0)
|
|
return value;
|
|
else return defaultValue;
|
|
}
|
|
|
|
public static int value(String value, int defaultValue) {
|
|
if (StrUtil.isEmpty(value) || "0".equals(value))
|
|
return defaultValue;
|
|
else return Integer.parseInt(value);
|
|
|
|
}
|
|
|
|
}
|