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

org.dflib.exp.Condition2 Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package org.dflib.exp;


import org.dflib.BooleanSeries;
import org.dflib.Condition;
import org.dflib.DataFrame;
import org.dflib.Exp;
import org.dflib.Series;

/**
 * @since 0.11
 */
public abstract class Condition2 implements Condition {

    private final String opName;
    protected final Exp left;
    protected final Exp right;

    public Condition2(String opName, Exp left, Exp right) {
        this.opName = opName;
        this.left = left;
        this.right = right;
    }

    @Override
    public String toString() {
        return toQL();
    }

    // TODO: space between the operand and arguments
    public String toQL() {
        return left.toQL() + opName + right.toQL();
    }

    @Override
    public String toQL(DataFrame df) {
        return left.toQL(df) + opName + right.toQL(df);
    }

    @Override
    public BooleanSeries eval(DataFrame df) {
        return doEval(left.eval(df), right.eval(df));
    }

    @Override
    public BooleanSeries eval(Series s) {
        return doEval(left.eval(s), right.eval(s));
    }

    protected abstract BooleanSeries doEval(Series left, Series right);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy