
package com.uwetrottmann.shopr.algorithm.model;

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

import java.math.BigDecimal;
import java.util.Arrays;

public class Price extends GenericAttribute {

    public static final String ID = "price";

    public enum Value implements AttributeValue {
        SUB_25("less than 25 €"),
        BETWEEN_25_50("25 to 50 €"),
        BETWEEN_50_100("50 to 100 €"),
        ABOVE_100("more than 100 €");

        private String mDescriptor;

        Value(String descriptor) {
            mDescriptor = descriptor;
        }

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

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

    }

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

    public Price(BigDecimal price) {
        mValueWeights = new double[Value.values().length];
        Arrays.fill(mValueWeights, 0.0);

        // determine price range
        Value value;
        if (price.doubleValue() < 25.0) {
            value = Value.SUB_25;
        } else if (price.doubleValue() < 50.0) {
            value = Value.BETWEEN_25_50;
        } else if (price.doubleValue() < 100.0) {
            value = Value.BETWEEN_50_100;
        } else {
            value = Value.ABOVE_100;
        }
        
        mValueWeights[value.ordinal()] = 1.0;
        currentValue(value);
    }

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

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

}

@@ -1471,17 +1471,9 @@
   %7D%0A
-        
 %0A
+
     
@@ -1673,24 +1673,24 @@
 Symbols() %7B%0A
-
         retu
@@ -1715,10 +1715,410 @@
 %0A    %7D%0A%0A
+    /**%0A     * Changes the behavior to also increase the weight of neighboring weights.%0A     * E.g. a user might like items priced in a little more expensive or a%0A     * little cheaper based on the price range he liked.%0A     */%0A    @Override%0A    public void likeValue(int valueIndex, double%5B%5D weights) %7B%0A        // TODO Auto-generated method stub%0A        super.likeValue(valueIndex, weights);%0A    %7D%0A%0A
 %7D%0A

Prepare custom likeValue for Price.