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

panda.el.opt.arithmetic.SubOpt Maven / Gradle / Ivy

Go to download

Panda Core is the core module of Panda Framework, it contains commonly used utility classes similar to apache-commons.

There is a newer version: 1.8.0
Show newest version
package panda.el.opt.arithmetic;

import panda.el.ELContext;
import panda.el.opt.AbstractTwoOpt;

/**
 * "-"
 */
public class SubOpt extends AbstractTwoOpt {

	public String operator() {
		return "-";
	}

	public int getPriority() {
		return 4;
	}

	public Object calculate(ELContext ec) {
		Number lval = (Number)getLeft(ec);
		Number rval = (Number)getRight(ec);

		if (isReturnNull(ec, lval, rval)) {
			return null;
		}

		if (rval instanceof Double || lval instanceof Double) {
			return lval.doubleValue() - rval.doubleValue();
		}
		if (rval instanceof Float || lval instanceof Float) {
			return lval.floatValue() - rval.floatValue();
		}
		if (rval instanceof Long || lval instanceof Long) {
			return lval.longValue() - rval.longValue();
		}
		return lval.intValue() - rval.intValue();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy