Created
February 28, 2016 05:27
-
-
Save ankushs92/69300c47c6cc1428986e to your computer and use it in GitHub Desktop.
Java : Check if a Number object has value null or 0.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NumberUtils{ | |
public boolean isNullOrZero(final Number number){ | |
return number == null || | |
( | |
number instanceof Integer ? number.intValue() == 0 : | |
number instanceof Long ? number.longValue() == 0 : | |
number instanceof Double ? number.doubleValue() == 0 : | |
number instanceof Short ? number.shortValue() == 0 : | |
number.floatValue() == 0 | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment