Java List Remove removeItems(List list, T... remove)

Here you can find the source of removeItems(List list, T... remove)

Description

Removes items from a list and returns that same list.

License

Apache License

Parameter

Parameter Description
T a parameter
list a parameter
remove a parameter

Declaration

public static <T> List<T> removeItems(List<T> list, T... remove) 

Method Source Code

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

import java.util.Arrays;
import java.util.Collection;

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

public class Main {
    /**/*from w  w w  .j a v a  2 s  . c o m*/
     * Removes items from a list and returns that same list. This will modify
     * the list passed in!
     * 
     * @param <T>
     * @param list
     * @param remove
     * @return
     */
    public static <T> List<T> removeItems(List<T> list, T... remove) {
        if (isEmpty(list))
            return null;
        list.removeAll(Arrays.asList(remove));

        return list;
    }

    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();
    }
}

Related

  1. removeFromArray(String[] fieldList, String exludeElement)
  2. removeFromListByClass(final List list, final String className)
  3. removeFromListMap(T key, U value, Map> map)
  4. removeIgnoreCase(List l, String s)
  5. removeIgnoreCase(String needle, List haystack)
  6. removeList(List l)
  7. removeMember(String[] list, String id)
  8. removeObject(List l, T o)
  9. removeObjectList(List list, V o)