package org.academiadecodigo.enuminatti.paint.grid;

/**
 * MIT License
 * (c) 2017 Ricardo Constantino
 */

public enum Swatch {
    WHITE('0'),
    BLACK('1'),
    GREEN('2'),
    RED('3'),
    BLUE('4');

    private char representation;

    Swatch(char representation) {
        this.representation = representation;
    }

    public Swatch getOpposite() {
        switch (this) {
            case WHITE:
                return BLACK;
            default:
                return WHITE;
        }
    }

    public Swatch getNextColor() {
        switch (this) {
            case BLUE:
                return BLACK;
            default:
                return Swatch.values()[this.ordinal()+1];
        }
    }

    public char toChar() {
        return representation;
    }

    public static Swatch fromChar(char c) {
        return Swatch.values()[Character.getNumericValue(c)];
    }
}
