Created
April 4, 2018 01:27
-
-
Save carlostse/119de051e9a4ec25ed4d1cd0fd293040 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Check if the object is null or empty | |
| * | |
| * @param obj - the test object | |
| * @return true if the value is missing | |
| */ | |
| public static boolean isMissing(Object obj) { | |
| if (obj == null) return true; | |
| if (obj instanceof CharSequence) return (obj).toString().trim().length() < 1; | |
| if (obj instanceof Collection) return ((Collection) obj).size() < 1; | |
| if (obj instanceof Map) return ((Map) obj).size() < 1; | |
| // more to come | |
| return false; // default just check not null | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment