com.softicar.platform.common.container.map.number.BigDecimalMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.container.map.number;
import com.softicar.platform.common.math.arithmetic.Arithmetics;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;
/**
* A {@link NumberMap} for {@link BigDecimal}.
*
* @param
* the type of the keys
* @author Oliver Richers
*/
public class BigDecimalMap extends NumberMap {
public BigDecimalMap() {
this(new TreeMap());
}
public BigDecimalMap(Comparator comparator) {
this(new TreeMap(comparator));
}
public BigDecimalMap(Map data) {
super(data, Arithmetics.BIG_DECIMAL);
}
public void round(int precision) {
for (K key: getDataContainer().keySet()) {
getDataContainer().put(key, getDataContainer().get(key).setScale(precision, RoundingMode.HALF_UP));
}
}
}