Java Reflection Primitive isPrimitiveWrapper(Class clazz)

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

Description

Check if the given class represents a primitive wrapper, i.e.

License

Open Source License

Parameter

Parameter Description
clazz the class to check

Return

whether the given class is a primitive wrapper class

Declaration

public static boolean isPrimitiveWrapper(Class<?> clazz) 

Method Source Code

//package com.java2s;

import java.util.HashMap;

import java.util.Map;

public class Main {
    /**//from  www. ja v  a  2  s .c om
     * Map with primitive wrapper type as key and corresponding primitive
     * type as value, for example: Integer.class -> int.class.
     */
    private static final Map<Class<?>, Class<?>> primitiveWrapperTypeMap = new HashMap<Class<?>, Class<?>>(8);

    /**
     * Check if the given class represents a primitive wrapper,
     * i.e. Boolean, Byte, Character, Short, Integer, Long, Float, or Double.
     * @param clazz the class to check
     * @return whether the given class is a primitive wrapper class
     */
    public static boolean isPrimitiveWrapper(Class<?> clazz) {
        if (clazz == null) {
            throw new IllegalArgumentException("Class must not be null");
        }
        return primitiveWrapperTypeMap.containsKey(clazz);
    }
}

Related

  1. isPrimitiveOrPrimitiveWrapper(final Class type)
  2. isPrimitiveOrWrapper(Class klass)
  3. isPrimitiveOrWrapper(Class type)
  4. isPrimitiveOrWrapper(final Class type)
  5. isPrimitiveWrapper(Class clazz)
  6. isPrimitiveWrapper(Class klass)
  7. isPrimitiveWrapper(final Class type)
  8. isPrimitiveWrapperArray(Class clazz)
  9. isPrimitiveWrapperClass(Class primitiveWrapperClass)