Apache Commons Lang has a utility method to do this (ClassUtils.primitiveToWrapper()), which will be just as ugly under the covers, but at least you can pretend it’s nice.
More Related Contents:
- How do I programmatically compile and instantiate a Java class?
- Modify a class definition’s annotation string parameter at runtime
- Gson TypeToken with dynamic ArrayList item type
- Java Reflection Performance
- Can I obtain method parameter name using Java reflection?
- How to create a generic array in Java?
- How to solve InaccessibleObjectException (“Unable to make {member} accessible: module {A} does not ‘opens {package}’ to {B}”) on Java 9?
- Get all of the Classes in the Classpath
- Printing debug info on errors with java 8 lambda expressions
- Instantiating object of type parameter
- How to convert a Java object (bean) to key-value pairs (and vice versa)?
- Copy all values from fields in one class to another through reflection
- Getting Class type from String
- Getting value of public static final field/property of a class in Java via reflection
- How != and == operators work on Integers in Java? [duplicate]
- How to get Method Parameter names in Java 8 using reflection?
- Changing private final fields via reflection
- Dumping a java object’s properties
- Check if a Class Object is subclass of another Class Object in Java
- How to work with varargs and reflection
- Java Reflection Beans Property API
- Java: newInstance of class that has no default constructor
- Java Reflection calling constructor with primitive types
- Determine if a Class implements a interface in Java
- How do I print the method body reflectively?
- Check type of primitive field
- Automatically delegating all methods of a java class
- Get value of a parameter of an annotation in Java
- Cast via reflection and use of Class.cast() [duplicate]
- Using jars that use java.beans classes (Introspector, BeanInfo or PropertyDescriptor)