Skip to content

Instantly share code, notes, and snippets.

@LenarBad
Created July 24, 2018 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LenarBad/6d7b9e79d61b8d11da791dabcc53f55f to your computer and use it in GitHub Desktop.
Save LenarBad/6d7b9e79d61b8d11da791dabcc53f55f to your computer and use it in GitHub Desktop.
Checks if object is auto-boxed primitive + String and Void
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;
}
@LenarBad
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment