Java examples for java.math:BigDecimal
all Null Or Zero BigDecimal
//package com.java2s; import java.math.BigDecimal; public class Main { public static void main(String[] argv) throws Exception { BigDecimal values = new BigDecimal("1234"); System.out.println(allNullOrZero(values)); }/*from ww w.ja va 2s . c o m*/ /** * @return true if all values are either null or zero */ public static boolean allNullOrZero(final BigDecimal... values) { for (final BigDecimal bd : values) { if (!isNullOrZero(bd)) { return false; } } return true; } /** * @return true if value ==null OR 0. */ public static boolean isNullOrZero(final BigDecimal value) { return value == null || value.signum() == 0; } /** * If value is null return 0 otherwise the signum(). * * @param value * @return */ public static int signum(final BigDecimal value) { return value == null ? 0 : value.signum(); } }