public class Grouping {
    @HRowKey(components = {
            @HFieldComponent(name = Constants.TIMEPERIOD, length = Bytes.SIZEOF_INT, type = Integer.class),
            @HFieldComponent(name = Constants.CATEGORY, length = Constants.LENGTH_CATEGORY_NAME, type = String.class)
    })
    public byte[] key;

    /**
     * format of the storage:
     * {product_id : {
     *     price_highest: int
     *     price_lowest: int
     *     manufacturer: String
     * }}
     */
    @HMapFamily(family = Constants.FAMILY_PRODUCT, keyType = String.class, valueType = Map.class)
    @HNestedMap(keyType = String.class, valueType = byte[].class)
    public Map<String, Map<String, byte[]>> product = new HashMap<String, Map<String, byte[]>>();

    public Grouping() {
    }

    protected String getStringEntry(String prodId, String key) {
        Map<String, byte[]> entry = product.get(prodId);
        if (entry == null || !entry.containsKey(key)) {
            return null;
        }
        return Bytes.toString(entry.get(key));
    }

    protected Integer getIntegerEntry(String prodId, String key) {
        Map<String, byte[]> entry = product.get(prodId);
        if (entry == null || !entry.containsKey(key)) {
            return null;
        }
        return Bytes.toInt(entry.get(key));
    }

  protected void setEntry(String prodId, String key, byte[] value) {
        Map<String, byte[]> entry = product.get(prodId);
        if (entry == null) {
            entry = new HashMap<String, byte[]>();
        }
        entry.put(key, value);
        product.put(prodId, entry);
    }

    public Integer getPriceHighest(String prodId) {
        return getIntegerEntry(prodId, Constants.PRICE_HIGHEST);
    }

    public void setPriceHighest(String prodId, int price) {
        setEntry(prodId, Constants.PRICE_HIGHEST, Bytes.toBytes(price));
    }

    public Integer getPriceLowest(String prodId) {
        return getIntegerEntry(prodId, Constants.PRICE_LOWEST);
    }

    public void setPriceLowest(String prodId, int price) {
        setEntry(prodId, Constants.PRICE_LOWEST, Bytes.toBytes(price));
    }

    public void getManufacturer(String prodId) {
        return getEntry(prodId, Constants.MANUFACTURER);
    }

    public void setManufacturer(String prodId, String manufacturer) {
        setEntry(prodId, Constants.MANUFACTURER, Bytes.toBytes(manufacturer));
    }
}