package net.squanchy.support.lang;

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

public final class Lists {

    public static <T, R> List<R> map(List<T> list, Func1<T, R> function) {
        if (list == null || list.isEmpty()) {
            return Collections.emptyList();
        }

        List<R> result = new ArrayList<>(list.size());
        for (T t : list) {
            result.add(function.call(t));
        }

        return result;
    }

    public static <T> T find(List<T> list, Func1<T, Boolean> predicate) {
        for (T t : list) {
            if (predicate.call(t)) {
                return t;
            }
        }

        // todo optional?
        return null;
    }

    public static <T, R> R reduce(R initial, List<T> list, Func2<R, T, R> reducer) {
        R reducedValue = initial;
        for (T t : list) {
            reducedValue = reducer.call(reducedValue, t);
        }

        return reducedValue;
    }
}

@@ -472,32 +472,415 @@
  result;%0A    %7D%0A%0A
+    public static %3CT%3E List%3CT%3E filter(List%3CT%3E list, Predicate%3CT%3E predicate) %7B%0A        if (list == null %7C%7C list.isEmpty()) %7B%0A            return Collections.emptyList();%0A        %7D%0A%0A        List%3CT%3E result = new ArrayList%3C%3E(list.size());%0A        for (T t : list) %7B%0A            if (predicate.call(t)) %7B%0A                result.add(t);%0A            %7D%0A        %7D%0A%0A        return result;%0A    %7D%0A%0A
     public stati

Create Lists.filter()