I am trying to validate a list to make the Value is not "NA" and not NULL. I am having trouble validting it since the list is a BigDecimal.
CODE:
List<BigDecimal> queryData = new ArrayList<BigDecimal>();
BigDecimal priceValue = null;
for (MBSTBABars tbaBar : tbaResults) {
priceValue = tbaBar.getTbaPrice();
if(priceValue.compareTo(BigDecimal.valueOf("NA")) ==0) { //Just want to make sure an entry is not "NA"
throw new Exception("Invalid Data Found In Query..Found: NULL");
}
if (priceValue != null &&(priceValue.compareTo(BigDecimal.valueOf(80)) >0 && priceValue.compareTo(BigDecimal.valueOf(130)) <0 )){
queryData.add(priceValue.stripTrailingZeros());
}else {
System.out.println("Value: " + priceValue +", is invalid valdiation failed.");
throw new Exception("Invalid Data Found In Query..Found: " + priceValue);
}
}
Any help find a solution to validate the list for "NA" would be appriciated.
Aucun commentaire:
Enregistrer un commentaire