반응형
String / Integer / Dto / Entity / List 어떤것이 와도 null인지 체크
public class ObjectUtils { public static boolean isEmpty(Object o) { if (ㅐ == null) { return true; } if ((o instanceof String) && (((String)o).trim().length() == 0)) { return true; } if (o instanceof Map) { return ((Map<?, ?>)o).isEmpty(); } if (o instanceof List) { return ((List<?>)o).isEmpty(); } if (o instanceof Object[]) { return (((Object[])o).length == 0); } return false; } } |
반응형
댓글