UnitOfMeasure.java

package com.tradecloud.domain.item;

import java.math.BigDecimal;

/**
 * Define UnitOfMeasure( e,g KG,M3) Type.
 * <p>
 * Created by ds on 8/27/14.
 */
public interface UnitOfMeasure {
    /**
     * ratio used to convert Unit to driving UnitType.
     * e.g weight is driven by (KG).
     *
     * @return ratio to do convertion.
     */
    BigDecimal getRatio();

    /**
     * check if unit is already already in {@code UnitType}.
     *
     * @return true if Unit is already in {@code UnitType}.
     */
    boolean convertToUnitType();

    /**
     * Do self convert to {@code UnitType}.
     *
     * @param numberToConvert
     * @return converted numberToConvert.
     */
    BigDecimal convert(BigDecimal numberToConvert);

    /**
     * enum for driving Unit types.
     */
    static enum UnitType {
        KG, M3;
    }

}