package vn.azteam.tpf.service.util;

import vn.azteam.tpf.Constants.Constants;

public class Unit {
    public static Double changeValueUnitWeightDouble(String unit, String uint_, Double index){
        if (unit.equals(Constants.UNIT_WEIGHT.g.name()) && uint_.equals(Constants.UNIT_WEIGHT.kg.name())){
            index = index/1000;
        } else if(unit.equals(Constants.UNIT_WEIGHT.kg.name()) && uint_.equals(Constants.UNIT_WEIGHT.g.name())){
            index = index*1000;
        } else if(unit.equals(Constants.UNIT_SIZE.m.name()) && uint_.equals(Constants.UNIT_SIZE.mm.name())){
            index = index*1000;
        }
        else if(unit.equals(Constants.UNIT_SIZE.mm.name()) && uint_.equals(Constants.UNIT_SIZE.m.name())){
            index = index/1000;
        }
        else if(unit.equals(Constants.UNIT_CAPACITY.ml.name()) && uint_.equals(Constants.UNIT_CAPACITY.l.name())){
            index = index/1000;
        }
        else if(unit.equals(Constants.UNIT_CAPACITY.l.name()) && uint_.equals(Constants.UNIT_CAPACITY.ml.name())){
            index = index/1000;
        }
        else {
            return index;
        }
        return index;
    }
}
