package sudoku.constraint;

import java.util.List;

import sudoku.structure.Sudoku;

public enum Constraint {

	Block("Bloc", new BlockConstraint()),
	Column("Colonne", new ColumnConstraint()),
	Line("Ligne", new LineConstraint()),
	Diagonal("Diagonale", new DiagonalConstraint());

	String displayName;
	IConstraint constraint;

	private Constraint(String displayName, IConstraint contraint) {
		this.constraint = contraint;
		this.displayName = displayName;
	}

	public boolean canBePlaced(Sudoku s, int x, int y, int newValue) {
		return getConstraint().canBePlaced(s, x, y, newValue);
	}

	public List<Integer> getPossibleSymbols(final Sudoku s, int x, int y) {
		return getConstraint().getPossibleSymbols(s, x, y);
	}

	public String getDisplayName() {
		return displayName;
	}

	public IConstraint getConstraint() {
		return constraint;
	}

	private static final String[] constraintNames;

	static {
		Constraint[] cons = Constraint.values();
		constraintNames = new String[cons.length];
		for (int i = 0; i < cons.length; i++) {
			constraintNames[i] = cons[i].getDisplayName();
		}
	}

	public static String[] getConstraintNames() {
		return constraintNames;
	}

}
