package org.dhatim.safesql.builder;

import org.dhatim.safesql.SafeSqlBuilder;

public class BooleanOperand implements Operand, Condition {

    private final boolean not;
    private final Expression expression;

    public BooleanOperand(Operand operand) {
        this(operand, false);
    }
    
    public BooleanOperand(Condition condition) {
        this(condition, false);
    }
    
    protected BooleanOperand(Expression expression, boolean not) {
        this.not = not;
        this.expression = expression;
    }
    
    protected Expression getExpression() {
        return expression;
    }
    
    protected boolean isNegative() {
        return not;
    }
    
    @Override
    public void appendTo(SafeSqlBuilder builder) {
        if (not) {
            builder.append("NOT ");
        }
        builder.append(expression);
    }

    @Override
    public BooleanOperand negate() {
        return new BooleanOperand(expression, !not);
    }
    
}

@@ -898,32 +898,399 @@
 ate() %7B%0A        
+BooleanOperand newOp;%0A        if (expression instanceof Condition) %7B%0A            Expression newExpr = ((Condition) expression).negate();%0A            newOp = create(newExpr, not);%0A        %7D else %7B%0A            newOp = create(expression, !not);%0A        %7D%0A        return newOp;%0A    %7D%0A    %0A    protected BooleanOperand create(Expression expression, boolean not) %7B%0A        
 return new Boole
@@ -1303,33 +1303,32 @@
 and(expression, 
-!
 not);%0A    %7D%0A    

Change negate body