Example usage for java.lang Class isArray

List of usage examples for java.lang Class isArray

Introduction

In this page you can find the example usage for java.lang Class isArray.

Prototype

@HotSpotIntrinsicCandidate
public native boolean isArray();

Source Link

Document

Determines if this Class object represents an array class.

Usage

From source file:com.github.yuxiaobin.mybatis.gm.GeneralSqlSessionFactoryBean.java

private boolean checkValidateClassTypes(Class<?> entityClazz) {
    return !ClassUtils.isPrimitiveOrWrapper(entityClazz) && !entityClazz.isArray() && !entityClazz.isInterface()
            && !Object.class.equals(entityClazz) && checkBeanType(entityClazz);
}

From source file:com.glaf.core.util.GetterUtils.java

public static float[] getFloatValues(Object value, float[] defaultValue) {
    if (value == null) {
        return defaultValue;
    }/*from  w  ww  .j  a v a 2s . com*/

    Class<?> clazz = value.getClass();

    if (clazz.isArray()) {
        Class<?> componentType = clazz.getComponentType();

        if (String.class.isAssignableFrom(componentType)) {
            return getFloatValues((String[]) value, defaultValue);
        } else if (Float.class.isAssignableFrom(componentType)) {
            return (float[]) value;
        }
    }

    return defaultValue;
}

From source file:com.glaf.core.util.GetterUtils.java

public static int[] getIntegerValues(Object value, int[] defaultValue) {
    if (value == null) {
        return defaultValue;
    }//from   www.j a v  a 2s . co m

    Class<?> clazz = value.getClass();

    if (clazz.isArray()) {
        Class<?> componentType = clazz.getComponentType();

        if (String.class.isAssignableFrom(componentType)) {
            return getIntegerValues((String[]) value, defaultValue);
        } else if (Integer.class.isAssignableFrom(componentType)) {
            return (int[]) value;
        }
    }

    return defaultValue;
}

From source file:com.glaf.core.util.GetterUtils.java

public static short[] getShortValues(Object value, short[] defaultValue) {
    if (value == null) {
        return defaultValue;
    }// w  w  w. j  a  v a 2 s  .c o  m

    Class<?> clazz = value.getClass();

    if (clazz.isArray()) {
        Class<?> componentType = clazz.getComponentType();

        if (String.class.isAssignableFrom(componentType)) {
            return getShortValues((String[]) value, defaultValue);
        } else if (Short.class.isAssignableFrom(componentType)) {
            return (short[]) value;
        }
    }

    return defaultValue;
}

From source file:com.glaf.core.util.GetterUtils.java

public static boolean[] getBooleanValues(Object value, boolean[] defaultValue) {

    if (value == null) {
        return defaultValue;
    }/*from w w  w. jav  a 2s  .c om*/

    Class<?> clazz = value.getClass();

    if (clazz.isArray()) {
        Class<?> componentType = clazz.getComponentType();

        if (String.class.isAssignableFrom(componentType)) {
            return getBooleanValues((String[]) value, defaultValue);
        } else if (Boolean.class.isAssignableFrom(componentType)) {
            return (boolean[]) value;
        }
    }

    return defaultValue;
}

From source file:com.glaf.core.util.GetterUtils.java

public static Date[] getDateValues(Object value, DateFormat dateFormat, Date[] defaultValue) {

    if (value == null) {
        return defaultValue;
    }//from  w w  w. j  a va  2  s. c  o m

    Class<?> clazz = value.getClass();

    if (clazz.isArray()) {
        Class<?> componentType = clazz.getComponentType();

        if (String.class.isAssignableFrom(componentType)) {
            return getDateValues((String[]) value, dateFormat, defaultValue);
        } else if (Date.class.isAssignableFrom(componentType)) {
            return (Date[]) value;
        }
    }

    return defaultValue;
}

From source file:com.glaf.core.util.GetterUtils.java

public static double[] getDoubleValues(Object value, double[] defaultValue) {

    if (value == null) {
        return defaultValue;
    }//from   ww  w  .java  2 s  .c  om

    Class<?> clazz = value.getClass();

    if (clazz.isArray()) {
        Class<?> componentType = clazz.getComponentType();

        if (String.class.isAssignableFrom(componentType)) {
            return getDoubleValues((String[]) value, defaultValue);
        } else if (Double.class.isAssignableFrom(componentType)) {
            return (double[]) value;
        }
    }

    return defaultValue;
}

From source file:com.glaf.core.util.GetterUtils.java

public static Number[] getNumberValues(Object value, Number[] defaultValue) {

    if (value == null) {
        return defaultValue;
    }/*from   w  w w .j a  v  a 2s  .c om*/

    Class<?> clazz = value.getClass();

    if (clazz.isArray()) {
        Class<?> componentType = clazz.getComponentType();

        if (String.class.isAssignableFrom(componentType)) {
            return getNumberValues((String[]) value, defaultValue);
        } else if (Number.class.isAssignableFrom(componentType)) {
            return (Number[]) value;
        }
    }

    return defaultValue;
}

From source file:de.fau.cs.osr.utils.SimpleTypeNameMapper.java

@Override
public String nameForType(Class<?> n) {
    String typeAlias = (String) typeToName.get(n);
    if (typeAlias != null)
        return typeAlias;

    if (n.isArray()) {
        ArrayInfo dim = ReflectionUtils.arrayDimension(n);
        String elementTypeName = nameForType(dim.elementClass);
        return elementTypeName + StringUtils.repeat("[]", dim.dim);
    }//from  ww  w.ja va 2  s .c  o m

    if (ReflectionUtils.isBasicDataType(n))
        return ReflectionUtils.abbreviateBasicDataTypeName(n);

    return nameForUnmappedType(n);
}

From source file:com.codenvy.cli.preferences.file.JsonPreferences.java

private boolean shouldMapUnmap(Class<?> clazz) {
    return !(simpleTypes.contains(clazz) || clazz.isPrimitive() || clazz.isArray()
            || Enum.class.isAssignableFrom(clazz) || Collection.class.isAssignableFrom(clazz));
}