Created
July 24, 2018 17:43
-
-
Save LenarBad/6d7b9e79d61b8d11da791dabcc53f55f to your computer and use it in GitHub Desktop.
Checks if object is auto-boxed primitive + String and Void
This file contains 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
public boolean isWiderPrimitive(Object object) { | |
if (object == null) { | |
return false; | |
} | |
Class clazz = object.getClass(); | |
if (clazz == Boolean.class || clazz == Character.class || | |
clazz == Byte.class || clazz == Short.class || | |
clazz == Integer.class || clazz == Long.class || | |
clazz == Float.class || clazz == Double.class || | |
clazz == String.class || clazz == Void.class) { | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Check if object is primitive in Java