![JAR search and dependency download from the Maven repository](/logo.png)
panda.el.opt.AbstractOpt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of panda-core Show documentation
Show all versions of panda-core Show documentation
Panda Core is the core module of Panda Framework, it contains commonly used utility classes similar to apache-commons.
package panda.el.opt;
import panda.el.ELContext;
import panda.el.ELException;
import panda.el.Operator;
import panda.el.obj.ELObj;
/**
* abstract class for Operator
*/
public abstract class AbstractOpt implements Operator {
/**
* @return the operator string
*/
public abstract String operator();
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj.equals(operator())) {
return true;
}
return super.equals(obj);
}
public String toString() {
return String.valueOf(operator());
}
/**
* calculate item
* @param ec EL Context
* @param obj object
* @return calculated result
*/
protected Object calculateItem(ELContext ec, Object obj) {
if (obj == null) {
return null;
}
if (obj instanceof Number) {
return obj;
}
if (obj instanceof Boolean) {
return obj;
}
if (obj instanceof String) {
return obj;
}
if (obj instanceof ELObj) {
return ((ELObj)obj).getObj(ec);
}
if (obj instanceof Operator) {
return ((Operator)obj).calculate(ec);
}
throw new ELException("Unknown calculate value: " + obj);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy