Skip to content

Instantly share code, notes, and snippets.

@ParkSangGwon
Created June 27, 2015 09:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ParkSangGwon/29025a812d135c5d4d76 to your computer and use it in GitHub Desktop.
Save ParkSangGwon/29025a812d135c5d4d76 to your computer and use it in GitHub Desktop.
public class ObjectUtils {
public static boolean isEmpty(Object s) {
if (s == null) {
return true;
}
if ((s instanceof String) && (((String)s).trim().length() == 0)) {
return true;
}
if (s instanceof Map) {
return ((Map<?, ?>)s).isEmpty();
}
if (s instanceof List) {
return ((List<?>)s).isEmpty();
}
if (s instanceof Object[]) {
return (((Object[])s).length == 0);
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment