List工具,做一些常见的判断操作

来源:互联网 发布:托福网络课程视频 编辑:程序博客网 时间:2024/05/16 19:08
import java.util.Collection;
import java.util.List;

public class ListUtil {
    public static boolean isEmpty(Collection<?> c) {
        if (c == null || c.isEmpty()) {
            return true;
        }
        return false;
    }

    public static boolean isNotEmpty(Collection<?> c) {
        if (c == null || c.isEmpty()) {
            return false;
        }
        return true;
    }

    public static boolean isInList(Object o, List<?> c) {
        if (o == null || c == null || c.isEmpty()) {
            return false;
        }
        for (Object t : c) {
            if (o.equals(t)) {
                return true;
            }
        }
        return false;
    }

    public static boolean strIgnoreCaseInList(String o, List<String> c) {
        if (o == null || c == null || c.isEmpty()) {
            return false;
        }
        for (String s : c) {
            if (o.equalsIgnoreCase(s)) {
                return true;
            }
        }
        return false;
    }

}

0 0
原创粉丝点击