Java List Contain containsAll(List list, T... items)

Here you can find the source of containsAll(List list, T... items)

Description

contains All

License

Apache License

Declaration

public static <T> boolean containsAll(List<T> list, T... items) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Collection;

import java.util.List;
import java.util.Map;

public class Main {
    public static <T> boolean containsAll(List<T> list, T... items) {
        if (isEmpty(list))
            return false;
        if (items == null || items.length < list.size())
            return false;

        // TODO This is not the most efficient search...
        for (T item : items)
            if (!list.contains(item))
                return false;

        return true;
    }/*from   w  ww.j  a va2  s.co  m*/

    public static boolean isEmpty(Iterable<?> i) {
        if (i instanceof Collection)
            return ((Collection<?>) i).isEmpty();
        return i == null || !i.iterator().hasNext();
    }

    public static boolean isEmpty(Map<?, ?> p_oCol) {
        return p_oCol == null || p_oCol.isEmpty();
    }

    public static int size(Collection<?> col) {
        return col == null ? 0 : col.size();
    }
}

Related

  1. contains(List list1, List list2)
  2. contains(List container, List list, Comparator comparator)
  3. contains(String str, List list)
  4. contains1(final String id, final List idList)
  5. containsAFloatingPointNumber(List values)
  6. containsAllIgnoreCase(List left, List right)
  7. containsAny(final String projectName, final List indicators)
  8. containsAny(List value, Object[] values)
  9. containsAny(Set theList, Set toSearch)