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

org.joo.libra.support.functions.SumFunction Maven / Gradle / Ivy

There is a newer version: 2.1.2
Show newest version
package org.joo.libra.support.functions;

import java.util.Arrays;

import org.joo.libra.PredicateContext;

public class SumFunction implements MultiArgsFunction {

	@Override
	public Object apply(PredicateContext context, Object[] t) {
		if (t == null || t.length == 0)
			throw new IllegalArgumentException("SUM function must have at least one argument");
		return Arrays.stream(t).map(number -> (Number) number).mapToDouble(number -> number.doubleValue()).sum();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy