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

org.nutz.el.opt.logic.OrOpt Maven / Gradle / Ivy

Go to download

Nutz, which is a collections of lightweight frameworks, each of them can be used independently

There is a newer version: 1.r.72
Show newest version
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 "||";
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy