import DataType from "../../../../parser/simple/DataType.js";
import { ReactiveBinaryExpression } from "../ReactiveBinaryExpression.js";

export class ReactiveGreaterThanOrEqual extends ReactiveBinaryExpression {
    /**
     *
     * @param {number} left
     * @param {number} right
     * @returns {boolean}
     */
    transform(left, right) {
        return left >= right;
    }

    /**
     *
     * @return {ReactiveGreaterThanOrEqual}
     */
    clone() {
        const r = new ReactiveGreaterThanOrEqual();

        r.copy(this);

        return r;
    }

    equals(other) {
        return (other.isReactiveGreaterThanOrEqual === true) && super.equals(other);
    }

    toCode() {
        return `( ${this.left.toCode()} >= ${this.right.toCode()} )`
    }

    /**
     *
     * @param {ReactiveExpression} left
     * @param {ReactiveExpression} right
     * @returns {ReactiveGreaterThanOrEqual}
     */
    static from(left, right) {
        const r = new ReactiveGreaterThanOrEqual();

        r.connect(left, right);

        return r;
    }

}

/**
 * @readonly
 * @type {DataType|string}
 */
ReactiveGreaterThanOrEqual.prototype.dataType = DataType.Boolean;

/**
 * @readonly
 * @type {boolean}
 */
ReactiveGreaterThanOrEqual.prototype.isComparativeExpression = true;

/**
 * @readonly
 * @type {boolean}
 */
ReactiveGreaterThanOrEqual.prototype.isReactiveGreaterThanOrEqual = true;
