How to determine whether the specified Class List is the parent class or subclass, whether it is an array

List 1 determines whether the parent class or parent interface, subclasses, and so on itself

/**
     * List is determined whether the specified class or subclass parent
     *
     * @Param clz
     * @return
     */
public static boolean isListTypeClass(Class clz) {
    try {
        return List.class.isAssignableFrom(clz) || clz.newInstance() instanceof List;
    } catch (Exception e) {
        return false;
    }
}

 

2. Determine if the specified class is an array type

/**
     * Determines whether the specified class is an array
     *
     * @Param clz
     * @return
     */
public static boolean isArrayTypeClass(Class clz) {
    return clz.isArray();
}

Guess you like

Origin www.cnblogs.com/duguxiaobiao/p/12091669.html