package hu.webarticum.jsatbuilder.builder.common;

import java.util.Collection;

import hu.webarticum.jsatbuilder.builder.core.Definition;
import hu.webarticum.jsatbuilder.solver.core.Solver;

public class AnyHelper extends AbstractLiteralListHelper {

    public AnyHelper(Definition... definitions) {
        super(definitions);
    }
    
    public AnyHelper(DefinitionLiteral... literals) {
        super(literals);
    }
    
    public AnyHelper(Collection<?> literalsOrDefinitions) {
        super(literalsOrDefinitions);
    }

    @Override
    public void fillSolver(Solver solver) {
        Solver.Clause backClause = new Solver.Clause();
        backClause.addLiteral(new Solver.Literal(this, true));
        
        for (Definition definition: getLiteralListManager().getDefinitions()) {
            Solver.Clause clause = new Solver.Clause();
            clause.addLiteral(new Solver.Literal(definition, false));
            clause.addLiteral(new Solver.Literal(this, true));
            solver.add(clause);
            
            backClause.addLiteral(new Solver.Literal(definition, true));
        }
        
        solver.add(backClause);
    }
    
}

@@ -691,35 +691,36 @@
 r.Literal(this, 
-tru
+fals
 e));%0A        %0A  
@@ -734,29 +734,30 @@
 or (
-Definition definition
+Solver.Literal literal
 : ge
@@ -781,26 +781,29 @@
 er().get
-Definition
+SolverLiteral
 s()) %7B%0A 
@@ -891,44 +891,27 @@
 ral(
-new Solver.Literal(definition, false
+literal.getNegated(
 ));%0A
@@ -1056,44 +1056,15 @@
 ral(
-new Solver.Literal(definition, true)
+literal
 );%0A 

Fix AnyHelper