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

io.burt.jmespath.function.SumFunction Maven / Gradle / Ivy

There is a newer version: 0.6.0
Show newest version
package io.burt.jmespath.function;

import java.util.List;

import io.burt.jmespath.Adapter;
import io.burt.jmespath.JmesPathType;

public class SumFunction extends ArrayMathFunction {
  public SumFunction() {
    super(ArgumentConstraints.typeOf(JmesPathType.NUMBER));
  }

  @Override
  protected  T performMathOperation(Adapter runtime, List values) {
    double sum = 0;
    for (T n : values) {
      sum += runtime.toNumber(n).doubleValue();
    }
    return runtime.createNumber(sum);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy