package org.metaborg.sdf2table.grammar.layoutconstraints;

import java.util.List;
import java.util.Objects;

import org.metaborg.sdf2table.grammar.ISymbol;

public class BooleanLayoutConstraint implements ILayoutConstraint {

    private static final long serialVersionUID = -3495667446825489885L;

    private final ILayoutConstraint c1;
    private final LayoutConstraintBooleanOperator op;
    private final ILayoutConstraint c2;

    public BooleanLayoutConstraint(ILayoutConstraint c1, LayoutConstraintBooleanOperator op, ILayoutConstraint c2) {
        this.c1 = c1;
        this.op = op;
        this.c2 = c2;
    }

    @Override public String toString() {
        if (this.op == LayoutConstraintBooleanOperator.NOT) {
            return this.op.toString() + " " + this.c1.toString();
        } else {
            return this.c1.toString() + " " + this.op.toString() + " " + this.c2.toString();
        }
    }

    public ILayoutConstraint getC1() {
        return this.c1;
    }

    public LayoutConstraintBooleanOperator getOp() {
        return this.op;
    }

    public ILayoutConstraint getC2() {
        return this.c2;
    }

    @Override public void normalizeConstraint(List<ISymbol> rhs) {
        this.c1.normalizeConstraint(rhs);
        this.c2.normalizeConstraint(rhs);
    }

    @Override public boolean equals(Object other) {
        if (!(other instanceof BooleanLayoutConstraint)) {
            return false;
        }
        if (this == other) {
            return true;
        }
        BooleanLayoutConstraint c = (BooleanLayoutConstraint) other;
        return Objects.equals(this.c1, c.c1) && this.op == c.op && Objects.equals(this.c2, c.c2);
    }
}

@@ -1242,24 +1242,90 @@
 raint(rhs);%0A
+        if (this.op != LayoutConstraintBooleanOperator.NOT) %7B%0A    
         this
@@ -1350,24 +1350,34 @@
 raint(rhs);%0A
+        %7D%0A
     %7D%0A%0A    @

Add check if boolean op is not