All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.touk.nussknacker.engine.functionUtils.CollectionUtils Maven / Gradle / Ivy

The newest version!
package pl.touk.nussknacker.engine.functionUtils;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

public class CollectionUtils {

    public static Set distinct(Collection collection) {
        return new HashSet<>(collection);
    }

    public static Number sum(Collection collection) {
        return collection.stream()
            .map(Number::longValue).reduce(0L, (a, b) -> a + b);
    }

}