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

io.tiler.internal.queries.expressions.functions.SumFunction Maven / Gradle / Ivy

There is a newer version: 0.1.28
Show newest version
package io.tiler.internal.queries.expressions.functions;

import io.tiler.internal.queries.QueryContext;
import io.tiler.internal.queries.expressions.Expression;

import java.util.List;

public class SumFunction extends ListFunction {
  private final Expression list;

  public SumFunction(QueryContext queryContext, Expression list) {
    super(queryContext, list, Number.class);
    this.list = list;
  }

  public Expression list() {
    return list;
  }

  @Override
  public Object applyToList(List list) {
    double sum = 0;

    for (Number item : list) {
      sum += item.doubleValue();
    }

    return sum;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy