Java Reflection Primitive isAJavaPrimitiveArrayClass(final Class type)

Here you can find the source of isAJavaPrimitiveArrayClass(final Class type)

Description

is A Java Primitive Array Class

License

Open Source License

Parameter

Parameter Description
type a parameter

Return

true if class is a primitive array class. Otherwise it returns false.

Declaration

public static boolean isAJavaPrimitiveArrayClass(final Class<?> type) 

Method Source Code

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

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/*from ww  w. j a  v a2 s  .  c o  m*/
     * 
     * @param type
     * @return true if class is a primitive array class. Otherwise it returns false.
     */
    public static boolean isAJavaPrimitiveArrayClass(final Class<?> type) {
        return getAllJavaPrimitiveArrayClasses().contains(type);
    }

    public static List<Class<?>> getAllJavaPrimitiveArrayClasses() {
        List<Class<?>> listAllClasses = getNumbersJavaPrimitiveArrayClasses();
        listAllClasses.addAll(getOtherJavaPrimitiveArrayClasses());
        return listAllClasses;
    }

    public static List<Class<?>> getNumbersJavaPrimitiveArrayClasses() {
        List<Class<?>> listClasses = new ArrayList<Class<?>>();
        listClasses.add(int[].class);
        listClasses.add(Integer[].class);
        listClasses.add(long[].class);
        listClasses.add(Long[].class);
        listClasses.add(double[].class);
        listClasses.add(Double[].class);
        listClasses.add(short[].class);
        listClasses.add(Short[].class);
        listClasses.add(float[].class);
        listClasses.add(Float[].class);
        return listClasses;
    }

    public static List<Class<?>> getOtherJavaPrimitiveArrayClasses() {
        List<Class<?>> listClasses = new ArrayList<Class<?>>();
        listClasses.add(char[].class);
        listClasses.add(Character[].class);
        listClasses.add(boolean[].class);
        listClasses.add(Boolean[].class);
        listClasses.add(String[].class);
        return listClasses;
    }
}

Related

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