
package com.uwetrottmann.shopr.algorithm.model;

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

import java.util.Arrays;

public class ClothingType extends GenericAttribute {

    public static final String ID = "clothing-type";

    public enum Value implements AttributeValue {
        SWIMSUIT("Swim suit"),
        TRUNKS("Trunks"),
        BRA("Bra"),
        BLOUSE("Blouse"),
        SHIRT("Shirt"),
        TROUSERS("Trouser"),
        JACKET("Jacket"),
        JEANS("Jeans"),
        DRESS("Dress"),
        POLOSHIRT("Poloshirt"),
        SWEATER("Sweater"), // Pullover
        SKIRT("Skirt"),
        SLIP("Slip"),
        PANTS("Pants"),
        BRIEFS("Briefs"), // Slip
        THONG("Thong"), // String
        CARDIGAN("Cardigan"), // Strickjacke
        STOCKING("Stocking"), // Strumpf
        PANTYHOSE("Pantyhose"), // Strumpfhose
        TSHIRT("T-Shirt"),
        TOP("Top"),
        UNDERSHIRT("Undershirt"),
        UNDERPANTS("Underpants"),
        SHORTS("Shorts");

        String mDescriptor;

        Value(String descriptor) {
            mDescriptor = descriptor;
        }

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

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

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

    public ClothingType(Value value) {
        setWeights(value);
    }

    public ClothingType(String name) {
        if ("Badeanzug".equals(name)) {
            setWeights(Value.SWIMSUIT);
        }
        else if ("Badehose".equals(name)) {
            setWeights(Value.TRUNKS);
        }
        else if ("BH".equals(name)) {
            setWeights(Value.BRA);
        }
        else if ("Bluse".equals(name)) {
            setWeights(Value.BLOUSE);
        }
        else if ("Hemd".equals(name) || "Shirt".equals(name)) {
            setWeights(Value.SHIRT);
        }
        else if ("Hose".equals(name)) {
            setWeights(Value.TROUSERS);
        }
        else if ("Jacke".equals(name)) {
            setWeights(Value.JACKET);
        }
        else if ("Jeans".equals(name)) {
            setWeights(Value.JEANS);
        }
        else if ("Kleid".equals(name)) {
            setWeights(Value.DRESS);
        }
        else if ("Poloshirt".equals(name)) {
            setWeights(Value.POLOSHIRT);
        }
        else if ("Pullover".equals(name)) {
            setWeights(Value.SWEATER);
        }
        else if ("Rock".equals(name)) {
            setWeights(Value.SKIRT);
        }
        else if ("Slip".equals(name)) {
            setWeights(Value.BRIEFS);
        }
        else if ("Stoffhose".equals(name)) {
            setWeights(Value.PANTS);
        }
        else if ("Strickjacke".equals(name)) {
            setWeights(Value.CARDIGAN);
        }
        else if ("String".equals(name)) {
            setWeights(Value.THONG);
        }
        else if ("Strumpf".equals(name)) {
            setWeights(Value.STOCKING);
        }
        else if ("Strumpfhose".equals(name)) {
            setWeights(Value.PANTYHOSE);
        }
        else if ("T-Shirt".equals(name)) {
            setWeights(Value.TSHIRT);
        }
        else if ("Top".equals(name)) {
            setWeights(Value.TOP);
        }
        else if ("Unterhemd".equals(name)) {
            setWeights(Value.UNDERSHIRT);
        }
        else if ("Unterhose".equals(name)) {
            setWeights(Value.UNDERPANTS);
        }
    }

    private void setWeights(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 Value[] getValueSymbols() {
        return Value.values();
    }

}

@@ -362,28 +362,8 @@
 %22),%0A
-        BRA(%22Bra%22),%0A
     
@@ -620,17 +620,21 @@
    S
-LIP(%22Slip
+HORTS(%22Shorts
 %22),%0A
@@ -661,76 +661,8 @@
 %22),%0A
-        BRIEFS(%22Briefs%22), // Slip%0A        THONG(%22Thong%22), // String%0A
     
@@ -714,225 +714,24 @@
     
-S
 TO
-CKING(%22Stocking%22), // Strumpf%0A        PANTYHOSE(%22Pantyhose%22), // Strumpfhose%0A        TSHIRT(%22T-Shirt%22),%0A        TOP(%22Top%22),%0A        UNDERSHIRT(%22Undershirt%22),%0A        UNDERPANTS(%22Underpants%22),%0A        SHORTS(%22Shorts
+P(%22Top/T-Shirt
 %22);%0A
@@ -1516,91 +1516,8 @@
   %7D%0A
-        else if (%22BH%22.equals(name)) %7B%0A            setWeights(Value.BRA);%0A        %7D%0A
     
@@ -1641,32 +1641,8 @@
 ame)
- %7C%7C %22Shirt%22.equals(name)
 ) %7B%0A
@@ -2323,96 +2323,8 @@
   %7D%0A
-        else if (%22Slip%22.equals(name)) %7B%0A            setWeights(Value.BRIEFS);%0A        %7D%0A
     
@@ -2530,104 +2530,11 @@
 f (%22
-String%22.equals(name)) %7B%0A            setWeights(Value.THONG);%0A        %7D%0A        else if (%22Strumpf
+Top
 %22.eq
@@ -2580,16 +2580,11 @@
 lue.
-S
 TO
-CKING
+P
 );%0A 
@@ -2615,112 +2615,13 @@
  (%22S
-trumpfhose%22.equals(name)) %7B%0A            setWeights(Value.PANTYHOSE);%0A        %7D%0A        else if (%22T-Shirt
+horts
 %22.eq
@@ -2667,290 +2667,12 @@
 lue.
-T
 SH
-IRT);%0A        %7D%0A        else if (%22Top%22.equals(name)) %7B%0A            setWeights(Value.TOP);%0A        %7D%0A        else if (%22Unterhemd%22.equals(name)) %7B%0A            setWeights(Value.UNDERSHIRT);%0A        %7D%0A        else if (%22Unterhose%22.equals(name)) %7B%0A            setWeights(Value.UNDERPAN
+OR
 TS);

Drop dropped types, add new 'Shorts' type.