Java Collection Add addCollections(Collection... inCollections)

Here you can find the source of addCollections(Collection... inCollections)

Description

add Collections

License

Open Source License

Declaration

@SafeVarargs
    public static <T> List<T> addCollections(Collection<T>... inCollections) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.Collection;

import java.util.List;

public class Main {
    @SafeVarargs
    public static <T> List<T> addCollections(Collection<T>... inCollections) {

        return addCollections(true, inCollections);
    }//from  w  w w  .  j ava  2  s.  c  om

    @SafeVarargs
    public static <T> List<T> addCollections(boolean inAddDuplicates, Collection<T>... inCollections) {

        final List<T> theList = new ArrayList<T>();

        if (inCollections != null) {

            for (Collection<T> aCollection : inCollections) {

                if (aCollection != null) {

                    for (T anItem : aCollection) {

                        if (!inAddDuplicates && theList.contains(anItem)) {
                            continue;
                        }
                        theList.add(anItem);
                    }
                }
            }
        }

        return theList;
    }
}

Related

  1. addArray(Collection col, T[] array)
  2. addArray(java.util.Collection v, T array[])
  3. addArrayToCollection(T[] array, Collection collection)
  4. addArrayToCollection(T[] array, Collection collection)
  5. addCheck(Collection c, Object o)
  6. addCondition(Collection conditions, String condition, double value)
  7. addConditionImpl(Collection conditions, String condition, String value)
  8. addDirToStringPaths(Collection ss, String dir)
  9. added(Collection old, Collection nu)