net.sf.aguacate.function.spi.impl.FunctionGreaterThanToday Maven / Gradle / Ivy
package net.sf.aguacate.function.spi.impl;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.Date;
import net.sf.aguacate.function.FunctionEvalResult;
import net.sf.aguacate.function.Parameter;
import net.sf.aguacate.function.spi.AbstractFunction1;
import net.sf.aguacate.util.time.TimeUtil;
public class FunctionGreaterThanToday extends AbstractFunction1 {
public FunctionGreaterThanToday(Collection methods, String name, String message, Parameter parameter) {
super(methods, name, message, parameter, null);
}
@Override
protected FunctionEvalResult evaluate(Object value) {
String msg = MessageFormat.format(getMessage(), value);
if (TimeUtil.today().compareTo((Date) value) >= 0) {
logFailure(msg);
return new FunctionEvalResult("Less or equals than today", null);
} else {
logSuccess(msg);
return new FunctionEvalResult(null, null);
}
}
}