I'm looking for some help cleaning up the code below and reducing the number of lines. Is there a way to not set anything if the get returns a null?
if (map.get("cpn_rate") != null) {
collateral.setCoupon(new BigDecimal(map.get("cpn_rate")));
}
if (map.get("Price") != null) {
collateral.setPrice(new BigDecimal(map.get("Price")));
}
if (map.get("Par") != null) {
collateral.setPar(new BigDecimal(map.get("Par")));
}
if (map.get("mkt_val") != null) {
collateral.setMarketValue(new BigDecimal(map.get("mkt_val")));
}
if (map.get("Accrued Intr") != null) {
collateral.setAccurInterest(new BigDecimal(map.get("Accrued Intr")));
}
if (map.get("Total Market Value") != null) {
collateral.setTotMktValue(new BigDecimal(map.get("Total Market Value")));
}