Java Utililty Methods List Union

List of utility methods to do List Union

Description

The list of methods to do List Union are organized into topic(s).

Method

Listunion(List list1, List list2, boolean duplicate)
union
if (list1 == null || list2 == null) {
    return (list1 == null) ? new ArrayList<T>(list2) : new ArrayList<T>(list1);
List<T> ret;
if (duplicate) {
    ret = new ArrayList<T>(list1);
    ret.addAll(list2);
} else {
...
Listunion(List set1, List set2)
union
List<T> unionSet = new ArrayList<T>(set1);
unionSet.addAll(set2);
return unionSet;
Listunion(List... lists)
Creates a union from all of the specified List s.
List<T> newList = new LinkedList<>();
for (List<T> list : lists) {
    newList.addAll(list);
return newList;
voidunionAdd(List vect, E obj)

This method adds obj to vect if and only if vect does not already contain obj.

if (obj == null) {
    return;
if (vect.contains(obj)) {
    return;
vect.add(obj);
StringunionCreditList(List list)
Creates the union of a list of credit ranges, returning the min and max credits found.
if (list == null || list.isEmpty())
    return "";
float minCredits = Integer.MAX_VALUE;
float maxCredits = Integer.MIN_VALUE;
for (String item : list) {
    String[] split = item.split("[ ,/-]");
    String first = split[0];
    float min = Float.parseFloat(first);
...
ListunionList(Collection col1, Collection col2)
union List
List<T> result = new ArrayList<>(col1.size() + col2.size());
result.addAll(col1);
result.addAll(col2);
return result;
ListunionList(List la, List lb)
union List
if (la == null) {
    la = new ArrayList<T>();
if (lb == null) {
    lb = new ArrayList<T>();
List<T> cpLa = new ArrayList<T>();
List<T> cpLb = new ArrayList<T>();
...
ListunionList(List list1, List list2)
Union list.
if (isEmpty(list1) && isEmpty(list2)) {
    return new ArrayList<T>();
if (isEmpty(list1) && !isEmpty(list2)) {
    return list2;
if (!isEmpty(list1) && isEmpty(list2)) {
    return list1;
...
SetunionOfListOfLists(final Collection> collectionOfCollection)
union Of List Of Lists
if (collectionOfCollection == null || collectionOfCollection.isEmpty()) {
    return Collections.emptySet();
final HashSet<T> union = new HashSet<T>();
for (final Collection<T> col : collectionOfCollection) {
    if (col != null) {
        for (final T t : col) {
            if (t != null) {
...
StringunionSeparator(List elements, String separator)
union Separator
final StringBuilder sb = new StringBuilder();
sb.append(elements.get(0));
for (int i = 1; i < elements.size(); i++) {
    sb.append(separator);
    sb.append(elements.get(i));
return sb.toString();