package com.github.blindpirate.gogradle.util;

import org.codehaus.groovy.runtime.DefaultGroovyMethods;

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

import static java.util.Arrays.asList;
import static java.util.Arrays.stream;

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

    public static <T> List<T> collectOptional(Optional<T>... optionals) {
        return stream(optionals)
                .reduce(new ArrayList<>(),
                        (list, optional) -> {
                            if (optional.isPresent()) {
                                list.add(optional.get());
                            }
                            return list;
                        },
                        Functions.returnFirstArg());
    }

    @SuppressWarnings("unchecked")
    public static <T> List<T> flatten(List<T>... lists) {
        return (List<T>) DefaultGroovyMethods.flatten(lists);
    }
}

@@ -122,24 +122,53 @@
 .ArrayList;%0A
+import java.util.Collection;%0A
 import java.
@@ -346,16 +346,121 @@
 Utils %7B%0A
+    public static %3CT%3E boolean isEmpty(Collection%3CT%3E c) %7B%0A        return c == null %7C%7C c.isEmpty();%0A    %7D%0A%0A
     publ

Add a util method