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

org.joo.libra.support.functions.SqrtFunction Maven / Gradle / Ivy

There is a newer version: 2.1.2
Show newest version
package org.joo.libra.support.functions;

import org.joo.libra.PredicateContext;

public class SqrtFunction implements MultiArgsFunction {

	@Override
	public Object apply(PredicateContext context, Object[] t) {
		if (t == null || t.length != 1)
			throw new IllegalArgumentException("SQRT function must have exactly one argument");
		if (!(t[0] instanceof Number))
			throw new IllegalArgumentException("SQRT argument must be a number");
		Number arg = (Number) t[0];
		return Math.sqrt(arg.doubleValue());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy