org.nutz.el.opt.logic.OrOpt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nutz Show documentation
Show all versions of nutz Show documentation
Nutz, which is a collections of lightweight frameworks, each of them can be used independently
package org.nutz.el.opt.logic;
import org.nutz.castor.Castors;
import org.nutz.el.opt.TwoTernary;
/**
* or(||)
*
* @author juqkai([email protected])
*
*/
public class OrOpt extends TwoTernary {
public int fetchPriority() {
return 12;
}
public Object calculate() {
Object lval = calculateItem(left);
if (null != lval) {
if (!(lval instanceof Boolean)) {
// throw new ElException("操作数类型错误!");
if (Castors.me().castTo(lval, Boolean.class)) {
return true;
}
} else if ((Boolean) lval) {
return true;
}
}
Object rval = calculateItem(right);
if (null != rval) {
if (!(rval instanceof Boolean)) {
// throw new ElException("操作数类型错误!");
return Castors.me().castTo(rval, Boolean.class);
}
if ((Boolean) rval) {
return true;
}
}
return false;
}
public String fetchSelf() {
return "||";
}
}