
package com.uwetrottmann.shopr.algorithm.model;

import com.uwetrottmann.shopr.algorithm.model.Attributes.AttributeValue;

import java.util.Arrays;

public class Color extends GenericAttribute {

    public static final String ID = "color";

    public enum Value implements AttributeValue {
        RED("Red"),
        BLUE("Blue"),
        GREEN("Green"),
        BLACK("Black");

        String mDescriptor;

        Value(String name) {
            mDescriptor = name;
        }

        @Override
        public String descriptor() {
            return mDescriptor;
        }

        @Override
        public int index() {
            return ordinal();
        }
    }

    public Color() {
        int numValues = Value.values().length;
        mValueWeights = new double[numValues];
        Arrays.fill(mValueWeights, 1.0 / numValues);
    }

    public Color(Value value) {
        mValueWeights = new double[Value.values().length];
        Arrays.fill(mValueWeights, 0.0);
        mValueWeights[value.ordinal()] = 1.0;
        currentValue(value);
    }

    @Override
    public String id() {
        return ID;
    }

    @Override
    public AttributeValue[] getValueSymbols() {
        return Value.values();
    }
}

@@ -298,86 +298,359 @@
     
-RED(%22Red%22),%0A        BLUE(%22Blue%22),%0A        GREEN(%22Green%22),%0A        BLACK(%22Black
+BLUE(%22Blue%22),%0A        BROWN(%22Brown%22),%0A        COLORED(%22Colored%22),%0A        YELLOW(%22Yellow%22),%0A        MIXED(%22Mixed%22),%0A        GREY(%22Grey%22),%0A        GREEN(%22Green%22),%0A        ORANGE(%22Orange%22),%0A        PINK(%22Pink%22), // rosa zu Deutsch%0A        RED(%22Red%22),%0A        BLACK(%22Black%22),%0A        TURQUOISE(%22Turquoise%22),%0A        VIOLET(%22Violet%22),%0A        WHITE(%22White
 %22);%0A
@@ -1146,24 +1146,1553 @@
 ue value) %7B%0A
+        setWeights(value);%0A    %7D%0A%0A    /**%0A     * Tries to match the given string with a %7B@link Color.Value%7D.%0A     */%0A    public Color(String value) %7B%0A        if (%22Blau%22.equals(value)) %7B%0A            setWeights(Color.Value.BLUE);%0A        %7D%0A        else if (%22Braun%22.equals(value)) %7B%0A            setWeights(Color.Value.BROWN);%0A        %7D%0A        else if (%22Bunt%22.equals(value)) %7B%0A            setWeights(Color.Value.COLORED);%0A        %7D%0A        else if (%22Gelb%22.equals(value)) %7B%0A            setWeights(Color.Value.YELLOW);%0A        %7D%0A        else if (%22Gemischt%22.equals(value)) %7B%0A            setWeights(Color.Value.MIXED);%0A        %7D%0A        else if (%22Grau%22.equals(value)) %7B%0A            setWeights(Color.Value.GREY);%0A        %7D%0A        else if (%22Gr%C3%BCn%22.equals(value)) %7B%0A            setWeights(Color.Value.GREEN);%0A        %7D%0A        else if (%22Orange%22.equals(value)) %7B%0A            setWeights(Color.Value.ORANGE);%0A        %7D%0A        else if (%22Rosa%22.equals(value)) %7B%0A            setWeights(Color.Value.PINK);%0A        %7D%0A        else if (%22Rot%22.equals(value)) %7B%0A            setWeights(Color.Value.RED);%0A        %7D%0A        else if (%22Schwarz%22.equals(value)) %7B%0A            setWeights(Color.Value.BLACK);%0A        %7D%0A        else if (%22T%C3%BCrkis%22.equals(value)) %7B%0A            setWeights(Color.Value.TURQUOISE);%0A        %7D%0A        else if (%22Violett%22.equals(value)) %7B%0A            setWeights(Color.Value.VIOLET);%0A        %7D%0A        else if (%22Wei%C3%9F%22.equals(value)) %7B%0A            setWeights(Color.Value.WHITE);%0A        %7D%0A    %7D%0A%0A    private void setWeights(Value value) %7B%0A
         mVal

Support new colors.