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

panda.el.opt.logic.GTOpt 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.logic;

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

/**
 * Great Than
 */
public class GTOpt extends AbstractTwoOpt {
	public int getPriority() {
		return 6;
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	public Object calculate(ELContext ec) {
		Comparable lval = (Comparable)getLeft(ec);
		Comparable rval = (Comparable)getRight(ec);

		if (lval == null || rval == null) {
			return false;
		}
		if (Classes.isFloatLike(lval.getClass()) || Classes.isFloatLike(rval.getClass())) {
			return ((Number)lval).doubleValue() > ((Number)rval).doubleValue();
		}
		if (Classes.isIntLike(lval.getClass()) || Classes.isIntLike(rval.getClass())) {
			return ((Number)lval).longValue() > ((Number)rval).longValue();
		}
		return lval.compareTo(rval) > 0;
	}

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy