Java Reflection Primitive isExtPrimitive(Class clazz)

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

Description

Class.isPrimitive only works for the built-in Java types (eg.

License

Apache License

Parameter

Parameter Description
clazz The class of the type to query.

Return

True if it's a "real" primitive data type of one of the "uppercase" variants, false otherwise.

Declaration

public static boolean isExtPrimitive(Class<?> clazz) 

Method Source Code

//package com.java2s;
/**/*from w w w . j  ava  2 s .c  o  m*/
 * Copyright 2011 The Open Source Research Group,
 *                University of Erlangen-N?rnberg
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.HashMap;
import java.util.Map;

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

    /**
     * Class.isPrimitive only works for the built-in Java types (eg. int,
     * boolean). This method only works for the "uppercase" variants of Java's
     * primitive types (eg. Integer, Boolean, ...).
     * 
     * @param clazz
     *            The class of the type to query.
     * @return True if it's a "real" primitive data type of one of the
     *         "uppercase" variants, false otherwise.
     */
    public static boolean isExtPrimitive(Class<?> clazz) {
        return ucToLcTypeMap.containsKey(clazz);
    }
}

Related

  1. getWrapperClass(String className)
  2. getWrapperClassForPrimitive(Class primitiveClass)
  3. getWrapperClassIfPrimitive(final Class clazz)
  4. isAJavaPrimitiveArrayClass(final Class type)
  5. isBoxed(Class boxedClass, Class primitiveClass)
  6. isNumber(Class type)
  7. isNumber(Class type)
  8. isNumber(Class clazz)
  9. isNumeric(Class operandClass)