package com.tibbo.aggregate.common.expression.function.math;

import org.apache.commons.math3.stat.descriptive.rank.Min;

import com.tibbo.aggregate.common.Cres;
import com.tibbo.aggregate.common.expression.Function;
import com.tibbo.aggregate.common.expression.function.AbstractSingleValueCollectorFunction;

public class MinFunction extends AbstractSingleValueCollectorFunction
{
  public MinFunction()
  {
    super(new Min(),"min", Function.GROUP_MATH, "(DataTable table, String field) OR (Double first, Double second)", "Double", Cres.get().getString("fDescMin"));
  }

  @Override
  protected Object compare(Number first, Number second)
  {
    return Math.min(first.doubleValue(), second.doubleValue());
  }
}
