Java Reflection Primitive resolvePrimitiveClassName(String name)

Here you can find the source of resolvePrimitiveClassName(String name)

Description

Resolve the given class name as primitive class, if appropriate, according to the JVM's naming rules for primitive classes.

License

Open Source License

Parameter

Parameter Description
name the name of the potentially primitive class

Return

the primitive class, or null if the name does not denote a primitive class or primitive array class

Declaration

public static Class resolvePrimitiveClassName(String name) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.HashMap;

import java.util.Map;

public class Main {

    private static final Map primitiveTypeNameMap = new HashMap(16);

    /**//  w  w  w  . ja v a 2s.c  o m
     * Resolve the given class name as primitive class, if appropriate,
     * according to the JVM's naming rules for primitive classes.
     * <p>
     * Also supports the JVM's internal class names for primitive arrays. Does
     * <i>not</i> support the "[]" suffix notation for primitive arrays; this is
     * only supported by {@link #forName}.
     * @param name
     *            the name of the potentially primitive class
     * @return the primitive class, or <code>null</code> if the name does not
     *         denote a primitive class or primitive array class
     */
    public static Class resolvePrimitiveClassName(String name) {
        Class result = null;
        // Most class names will be quite long, considering that they
        // SHOULD sit in a package, so a length check is worthwhile.
        if (name != null && name.length() <= 8) {
            // Could be a primitive - likely.
            result = (Class) primitiveTypeNameMap.get(name);
        }
        return result;
    }
}

Related

  1. matchPrimitive(Class paramType, Object arg)
  2. primitiveArraysForName(String className)
  3. primitiveToWrapper(final Class cls)
  4. primitiveToWrapper(final Class cls)
  5. resolveClassPrimitiveAware(String className)
  6. resolvePrimitiveClassName(String name)
  7. resolvePrimitiveIfNecessary(Class clazz)
  8. resolvePrimitiveType(Class clazz)
  9. toPrimitive(String primitiveJson, Class clazz)