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

panda.el.opt.arithmetic.MulOpt 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;

/**
 * "x"
 */
public class MulOpt extends AbstractTwoOpt {
	public int getPriority() {
		return 3;
	}

	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();
	}

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy