public static <T> List<T> castList(Object obj, Class<T> clazz) {
        List<T> result = new ArrayList<T>();
        if (obj instanceof List<?>) {
            for (Object o : (List<?>) obj) {
                result.add(clazz.cast(o));
            }
            return result;
        }
        return null;
}

 

posted on 2020-12-03 16:19  西门夜说  阅读(1799)  评论(0编辑  收藏  举报