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

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

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

  public Expression list() {
    return list;
  }

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

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

      if (max == null || doubleValue > max) {
        max = doubleValue;
      }
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy