public static boolean isListOfType(Object instance, Class type) {

        if (instance == null || type == null) {
            return false;
        }

        if (List.class.isAssignableFrom(instance.getClass())) {

            // check whether the list is empty or the first instance is of passed type
            List list = (List) instance;
            boolean isEmpty = list.size() == 0;

            for (Object element : list) {
                if (element != null && !type.isAssignableFrom(element.getClass())) {
                    return false;
                }
            }

            return true;

        }

        return false;
    }
public static boolean isListOfType(Object instance, Class type) {

        if (instance == null || type == null) {
            return false;
        }

        if (List.class.isAssignableFrom(instance.getClass())) {

            
            List list = (List) instance;
            boolean isEmpty = list.size() == 0;

            for (Object element : list) {
                if (element != null && !type.isAssignableFrom(element.getClass())) {
                    return false;
                }
            }

            return true;

        }

        return false;
    }
public static boolean isListOfType ( Object instance , Class type ) { if ( instance == null || type == null ) { return false ; } if ( List . class . isAssignableFrom ( instance . getClass ( ) ) ) { // check whether the list is empty or the first instance is of passed type List list = ( List ) instance ; boolean isEmpty = list . size ( ) == 0 ; for ( Object element : list ) { if ( element != null && ! type . isAssignableFrom ( element . getClass ( ) ) ) { return false ; } } return true ; } return false ; }
Checks if passed instance is of type {@link java.util.List} and contains elements of the passed type.
Warning: Only the first element of the list will be checked

@param instance
@param type
@return
Checks if passed instance is of type { @link java . util . List } and contains elements of the passed type . Warning : Only the first element of the list will be checked