All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xyz.felh.utils.ListUtils Maven / Gradle / Ivy

There is a newer version: 4.0.2024102501
Show newest version
package xyz.felh.utils;

import java.util.ArrayList;
import java.util.List;

public class ListUtils {

    /**
     * Cast object to List
     *
     * @param obj   object
     * @param clazz class
     * @param    Type
     * @return the list
     */
    public static  List castList(Object obj, Class clazz) {
        List result = new ArrayList<>();
        if (obj instanceof List) {
            for (Object o : (List) obj) {
                result.add(clazz.cast(o));
            }
            return result;
        }
        return null;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy