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

io.tiler.internal.queries.expressions.functions.MinFunction 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 MinFunction extends ListFunction {
  private final Expression list;

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

  public Expression list() {
    return list;
  }

  @Override
  public Object applyToList(List list) {
    Double min = null;

    for (Number value : list) {
      double doubleValue = value.doubleValue();

      if (min == null || doubleValue < min) {
        min = doubleValue;
      }
    }

    return min == null ? Double.NaN : min;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy