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

net.sf.aguacate.function.spi.impl.FunctionLessThan Maven / Gradle / Ivy

There is a newer version: 0.10.9
Show newest version
package net.sf.aguacate.function.spi.impl;

import java.text.MessageFormat;
import java.util.Collection;

import net.sf.aguacate.function.FunctionEvalResult;
import net.sf.aguacate.function.Parameter;
import net.sf.aguacate.function.spi.AbstractFunction2;

public class FunctionLessThan> extends AbstractFunction2 {

	public FunctionLessThan(Collection methods, String name, String message, Parameter parameter1,
			Parameter parameter2) {
		super(methods, name, message, parameter1, parameter2, null);
	}

	@SuppressWarnings("unchecked")
	@Override
	protected FunctionEvalResult evaluate(Object value1, Object value2) {
		String msg = MessageFormat.format(getMessage(), value1, value2);
		if (compare((T) value1, (T) value2) < 0) {
			logSuccess(msg);
			return new FunctionEvalResult(null, null);
		} else {
			logFailure(msg);
			return new FunctionEvalResult("Not Less Than", null);
		}
	}

	int compare(T value1, T value2) {
		return value1.compareTo(value2);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy