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

org.nutz.el.opt.logic.AndOpt 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;

/**
 * and
 * 
 * @author juqkai([email protected])
 *
 */
public class AndOpt extends TwoTernary {
    public int fetchPriority() {
        return 11;
    }

    public Object calculate() {
        Object lval = calculateItem(this.left);
        if (null == lval)
            return false;

        if (!(lval instanceof Boolean)) {
            // throw new ElException("操作数类型错误!");
            if (!Castors.me().castTo(lval, Boolean.class)) {
                return false;
            }
        } else if (!(Boolean) lval) {
            return false;
        }

        Object rval = calculateItem(this.right);
        if (null == rval)
            return false;
        if (!(rval instanceof Boolean)) {
            // throw new ElException("操作数类型错误!");
            return Castors.me().castTo(rval, Boolean.class);
        }
        return (Boolean) rval;
    }

    public String fetchSelf() {
        return "&&";
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy