Java Reflection Primitive getWrapperClass(Class clazz)

Here you can find the source of getWrapperClass(Class clazz)

Description

returns the Object Type class of a primitive class type.

License

Open Source License

Parameter

Parameter Description
clazz a parameter

Return

Class

Declaration

public static Class<?> getWrapperClass(Class<?> clazz) 

Method Source Code


//package com.java2s;
/*//w  w  w .  j  a va  2  s. c  om
 * Copyright (c) 2007-2016 Centimia Ltd.
 * All rights reserved.  Unpublished -- rights reserved
 *
 * Use of a copyright notice is precautionary only, and does
 * not imply publication or disclosure.
 *  
 * Multiple-Licensed under the H2 License,
 * Version 1.0, and under the Eclipse Public License, Version 1.0
 * (http://h2database.com/html/license.html).
 * Initial Developer: H2 Group, Centimia Inc.
 */

import java.util.HashMap;

public class Main {
    private static HashMap<Class<?>, Class<?>> map = new HashMap<Class<?>, Class<?>>();

    /**
     * returns the Object Type class of a primitive class type. i.e. int.class returns Integer.class
     * @param clazz
     * @return Class<?>
     */
    public static Class<?> getWrapperClass(Class<?> clazz) {
        if (clazz.isPrimitive())
            return map.get(clazz);
        return clazz;
    }
}

Related

  1. getPrimitiveWrapper(Class primitiveType)
  2. getRank(Class aNumberClass)
  3. getWrapper(Class clazz)
  4. getWrapper(Class type)
  5. getWrapper(final Class beanClass)
  6. getWrapperClass(Class primitiveClass)
  7. getWrapperClass(String className)
  8. getWrapperClassForPrimitive(Class primitiveClass)
  9. getWrapperClassIfPrimitive(final Class clazz)