com.github.yydf.struts.util.ObjectUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of struts Show documentation
Show all versions of struts Show documentation
A simple, light Java WEB + ORM framework.
The newest version!
package com.github.yydf.struts.util;
import java.math.BigDecimal;
public class ObjectUtils {
public static Object[] mergeArray(Object[] array, Object... args) {
if (array.length == 0 && args.length == 0)
return new Object[0];
if (array.length == 0)
return args;
if (args.length == 0)
return array;
Object[] temp = new Object[array.length + args.length];
System.arraycopy(array, 0, temp, 0, array.length);
System.arraycopy(args, 0, temp, array.length, args.length);
return temp;
}
public static Integer toInteger(Object obj) {
if (StringUtils.isEmpty(obj))
return null;
if (obj instanceof BigDecimal)
return ((BigDecimal) obj).intValue();
return Integer.parseInt(obj.toString());
}
public static Long toLong(Object obj) {
if (StringUtils.isEmpty(obj))
return null;
return Long.parseLong(obj.toString());
}
public static Double toDouble(Object obj) {
if (StringUtils.isEmpty(obj))
return null;
return Double.parseDouble(obj.toString());
}
public static Boolean toBoolean(Object obj) {
if (StringUtils.isEmpty(obj))
return null;
return Boolean.parseBoolean(obj.toString());
}
}