public static final boolean checkIfZero ( String value , Class valueClazz ) { boolean returnValue = false ; if ( value != null && NumberUtils . isNumber ( value ) && numberTypes . get ( valueClazz ) != null ) { switch ( numberTypes . get ( valueClazz ) ) { case INTEGER : returnValue = Integer . parseInt ( value ) == ( NumberUtils . INTEGER_ZERO ) ; break ; case FLOAT : returnValue = Float . parseFloat ( value ) == ( NumberUtils . FLOAT_ZERO ) ; break ; case LONG : returnValue = Long . parseLong ( value ) == ( NumberUtils . LONG_ZERO ) ; break ; case BIGDECIMAL : // Note: cannot use 'equals' here - it would require both BigDecimals to have // the same scale. returnValue = ( new BigDecimal ( value ) ) . compareTo ( BigDecimal . ZERO ) == 0 ; break ; case BIGINTEGER : returnValue = ( new BigInteger ( value ) ) . equals ( BigInteger . ZERO ) ; break ; case SHORT : returnValue = ( new Short ( value ) ) . shortValue ( ) == NumberUtils . SHORT_ZERO . shortValue ( ) ; break ; } } return returnValue ; }
Check if zero