Java BigDecimal Add addToBigDecimalInMap(Object key, BigDecimal value, Map theMap)

Here you can find the source of addToBigDecimalInMap(Object key, BigDecimal value, Map theMap)

Description

add To Big Decimal In Map

License

Creative Commons License

Declaration

@SuppressWarnings("unchecked")
    public static void addToBigDecimalInMap(Object key, BigDecimal value, Map theMap) 

Method Source Code


//package com.java2s;
/*//from w  w  w. j  a  v a  2  s.  c o  m
 * This software is in the public domain under CC0 1.0 Universal plus a
 * Grant of Patent License.
 *
 * To the extent possible under law, the author(s) have dedicated all
 * copyright and related and neighboring rights to this software to the
 * public domain worldwide. This software is distributed without any
 * warranty.
 *
 * You should have received a copy of the CC0 Public Domain Dedication
 * along with this software (see the LICENSE.md file). If not, see
 * <http://creativecommons.org/publicdomain/zero/1.0/>.
 */

import java.math.BigDecimal;

import java.util.*;

public class Main {
    @SuppressWarnings("unchecked")
    public static void addToBigDecimalInMap(Object key, BigDecimal value, Map theMap) {
        if (value == null || theMap == null)
            return;
        Object curObj = theMap.get(key);
        if (curObj == null) {
            theMap.put(key, value);
        } else {
            BigDecimal curVal;
            if (curObj instanceof BigDecimal)
                curVal = (BigDecimal) curObj;
            else
                curVal = new BigDecimal(curObj.toString());
            theMap.put(key, curVal.add(value));
        }
    }
}

Related

  1. addBigDecimalsInMap(Map baseMap, Map addMap)
  2. addPercent(BigDecimal price, double amount)
  3. addQtde(BigDecimal val1, BigDecimal val2)
  4. addSalePrice(Map complexSalePrice, BigDecimal saleprice)
  5. addToBigDecimalInMap(Map theMap, K mapKey, BigDecimal addNumber)
  6. addUlp(BigDecimal x)
  7. addVAT(int priceInCents, BigDecimal vat)
  8. addVatAmount(BigDecimal percentage, BigDecimal amount)
  9. sum(BigDecimal num1, BigDecimal num2, int scale)