You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Xeno Amess <xe...@gmail.com> on 2020/05/30 14:53:35 UTC
[bean-utils] MethodUtils.getPrimitiveWrapper : should we consider
about Void and void?
right now the logic is :
/**
* Gets the wrapper object class for the given primitive type class.
* For example, passing {@code boolean.class</code> returns <code>Boolean.class}
* @param primitiveType the primitive type class for which a match is
to be found
* @return the wrapper type associated with the given primitive
* or null if no match is found
*/
public static Class<?> getPrimitiveWrapper(final Class<?> primitiveType) {
// does anyone know a better strategy than comparing names?
if (boolean.class.equals(primitiveType)) {
return Boolean.class;
} else if (float.class.equals(primitiveType)) {
return Float.class;
} else if (long.class.equals(primitiveType)) {
return Long.class;
} else if (int.class.equals(primitiveType)) {
return Integer.class;
} else if (short.class.equals(primitiveType)) {
return Short.class;
} else if (byte.class.equals(primitiveType)) {
return Byte.class;
} else if (double.class.equals(primitiveType)) {
return Double.class;
} else if (char.class.equals(primitiveType)) {
return Character.class;
} else {
return null;
}
}
I know void can never be a class of a parameter of a function, but should
we consider about adding logics for void and Void?
after all void.class.isPrimitive() is true...
same question with function getPrimitiveType