package com.github.blindpirate.gogradle.util;

import com.google.common.base.Optional;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class CollectionUtils {
    public static <T> List<T> immutableList(T... elements) {
        return Collections.unmodifiableList(Arrays.asList(elements));
    }

    public static <T> List<T> collectOptional(Optional<T>... optionals) {
        List<T> ret = new ArrayList<>();
        for (Optional<T> optional : optionals) {
            if (optional.isPresent()) {
                ret.add(optional.get());
            }
        }

        return ret;
    }

    public static <T> List<T> flatten(List<T>... lists) {
        List<T> result = new ArrayList<>();
        for (List<T> list : lists) {
            result.addAll(list);
        }
        return result;
    }
}

@@ -134,16 +134,45 @@
 Arrays;%0A
+import java.util.Collection;%0A
 import j
@@ -893,11 +893,116 @@
 t;%0A    %7D
+%0A%0A    public static %3CT%3E boolean isEmpty(Collection%3CT%3E c) %7B%0A        return c == null %7C%7C c.isEmpty();%0A    %7D
 %0A%7D%0A

add a util method