Java Reflection Primitive isWrapper(Class clazz)

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

Description

Returns information whether the given class is the wrapper class.

License

Apache License

Parameter

Parameter Description
clazz the class type to check.

Return

true if given class type is wrapper class; false otherwise.

Declaration

public static boolean isWrapper(Class<?> clazz) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Arrays;
import java.util.List;

public class Main {
    /** Constant for array of wrapper (object) types. */
    @SuppressWarnings("rawtypes")
    //@formatter:off
    private static final List<Class> wrappers = Arrays.asList(new Class[] { Integer.class, Double.class, Byte.class,
            Boolean.class, Character.class, Void.class, Short.class, Float.class, Long.class });

    /**/*  w ww .j ava  2  s.  c  om*/
     * Returns information whether the given class is the wrapper class.
     *
     * @param clazz the class type to check.
     * @return <code>true</code> if given class type is wrapper class; <code>false</code> otherwise.
     */
    public static boolean isWrapper(Class<?> clazz) {
        return wrappers.contains(clazz);
    }
}

Related

  1. isPrimitiveWrapper(Class clazz)
  2. isPrimitiveWrapper(Class klass)
  3. isPrimitiveWrapper(final Class type)
  4. isPrimitiveWrapperArray(Class clazz)
  5. isPrimitiveWrapperClass(Class primitiveWrapperClass)
  6. isWrapper(Class dataType)
  7. isWrapperAndPrimitivePair(Class c1, Class c2)
  8. isWrapperClass(Class clazz)
  9. isWrapperType(Class type)