tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Commons Bean Utils > Wrapper to Primitive

Wrapper to Primitive 

Apache Commons BeanUtils is a java library useful for accessing bean properties and methods. It provides introspection capabilities to view and manipulate the properties and operations provided by the given class. This requires the libraries commons-beanutils-1.8.3.jar, commons-beanutils-bean-collections-1.8.3.jar, commons-beanutils-core-1.8.3.jar, commons-collections-3.2.1.jar, commons-logging.jar to be in classpath. The following example shows using MethodUtils.getPrimitiveType() API. It returns the primitive type for the given wrapper object class.

File Name  :  
Author  :  Sudhakar KV
Email  :  [email protected]
package com.bethecoder.tutorials.commons_beanutils;

import org.apache.commons.beanutils.MethodUtils;

public class Wrapper2PrimitiveTest {

   @param args
  public static void main(String[] args) {
    Class<?> primitiveType = MethodUtils.getPrimitiveType(Integer.class);
    primitiveType = MethodUtils.getPrimitiveType(Character.class);
    primitiveType = MethodUtils.getPrimitiveType(Short.class);
    primitiveType = MethodUtils.getPrimitiveType(Double.class);


It gives the following output,


bl  br