Java Reflection Primitive getPrimitiveClass(Class wrapperClazz)

Here you can find the source of getPrimitiveClass(Class wrapperClazz)

Description

get Primitive Class

License

Open Source License

Declaration

public static Class<?> getPrimitiveClass(Class<?> wrapperClazz) 

Method Source Code

//package com.java2s;
/* /*  w ww  . jav  a2  s  .c o  m*/
  Copyright (C) 2013 Raquel Pau and Albert Coroleu.
     
 Walkmod is free software: you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
     
 Walkmod is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Lesser General Public License for more details.
     
 You should have received a copy of the GNU Lesser General Public License
 along with Walkmod.  If not, see <http://www.gnu.org/licenses/>.*/

import java.util.HashMap;

import java.util.Map;

public class Main {
    private static Map<String, Class<?>> primitiveClasses = new HashMap<String, Class<?>>();
    private static Map<String, String> wrapperClasses = new HashMap<String, String>();

    public static Class<?> getPrimitiveClass(Class<?> wrapperClazz) {
        if (isPrimitiveWrapperClass(wrapperClazz)) {
            return getPrimitiveClass(wrapperClasses.get(wrapperClazz.getName()));
        }
        return null;
    }

    public static Class<?> getPrimitiveClass(String name) {
        return primitiveClasses.get(name);
    }

    public static boolean isPrimitiveWrapperClass(Class<?> clazz) {
        return wrapperClasses.containsKey(clazz.getName());
    }
}

Related

  1. getDefaultValue(Class primitive)
  2. getDefaultValueForPrimitive(Class type)
  3. getNullOrPrimitiveDefault(Class to)
  4. getPrimitive(final String classname)
  5. getPrimitiveClass(Class wrapper)
  6. getPrimitiveClass(Class boxedClass)
  7. getPrimitiveClass(String name)
  8. getPrimitiveClass(String primitiveClassName)
  9. getPrimitiveClass(String primitiveName)