package jrummikub.ai.fdsolver; import java.util.List; import jrummikub.ai.fdsolver.constraint.Filter; import jrummikub.ai.fdsolver.constraint.FilterConstraint; import jrummikub.ai.fdsolver.constraint.IfConstraint; import jrummikub.ai.fdsolver.constraint.IndexConstraint; import jrummikub.ai.fdsolver.constraint.LessThan; import jrummikub.ai.fdsolver.constraint.OffsetConstraint; import jrummikub.ai.fdsolver.constraint.SameConstraint; import jrummikub.ai.fdsolver.constraint.SumConstraint; public class Constraints { public static Constraint when(Var cond, Constraint c) { return new IfConstraint(false, cond, c); } public static Constraint unless(Var cond, Constraint c) { return new IfConstraint(true, cond, c); } public static Constraint index(Var target, Var index, List> list) { return new IndexConstraint(target, index, list); } public static Constraint constant(Var target, final T constant) { return new FilterConstraint(new Filter() { @Override public boolean accept(T value) { return value.equals(constant); } }, target); } public static Constraint offset(int offset, Var x, Var y) { return new OffsetConstraint(offset, x, y); } public static Constraint same(Var x, Var y) { return new SameConstraint(x, y); } public static Constraint sum(Var x, Var y, Var z) { return new SumConstraint(x, y, z); } public static > Constraint lessThan(Var x, Var y) { return new LessThan(false, x, y); } public static > Constraint lessThanEq(Var x, Var y) { return new LessThan(true, x, y); } }