@Test public void testIsFalsy() { assertTrue(Checker.isFalsy(null)); assertTrue(Checker.isFalsy(false)); assertTrue(Checker.isFalsy(new String[] {})); assertTrue(Checker.isFalsy(Collections.emptyList())); assertTrue(Checker.isFalsy("")); assertTrue(Checker.isFalsy(new StringBuilder())); assertTrue(Checker.isFalsy(0)); assertTrue(Checker.isFalsy(BigDecimal.ZERO)); assertTrue(Checker.isFalsy(new BigDecimal("0.000"))); assertFalse(Checker.isFalsy(Boolean.TRUE)); assertFalse(Checker.isFalsy(new Object[] { "foo" })); assertFalse(Checker.isFalsy(Collections.singleton("foo"))); assertFalse(Checker.isFalsy("foo")); assertFalse(Checker.isFalsy(new StringBuilder().append("foo"))); assertFalse(Checker.isFalsy(-10)); assertFalse(Checker.isFalsy(BigDecimal.TEN)); assertFalse(Checker.isFalsy(0.2)); assertFalse(Checker.isFalsy(new BigDecimal("-0.01"))); }
@SuppressWarnings("rawtypes") public static boolean isFalsy(Object value) { if (value == null) { return true; } else if (value instanceof Boolean) { return !(Boolean) value; } else if (value instanceof Collection) { return ((Collection) value).isEmpty(); } else if (value instanceof Iterable) { return !((Iterable) value).iterator().hasNext(); } else if (value.getClass().isArray()) { return Array.getLength(value) == 0; } else if (value instanceof CharSequence) { return ((CharSequence) value).length() == 0; } else if (value instanceof Number) { return isZero((Number) value); } return false; }
Checker { @SuppressWarnings("rawtypes") public static boolean isFalsy(Object value) { if (value == null) { return true; } else if (value instanceof Boolean) { return !(Boolean) value; } else if (value instanceof Collection) { return ((Collection) value).isEmpty(); } else if (value instanceof Iterable) { return !((Iterable) value).iterator().hasNext(); } else if (value.getClass().isArray()) { return Array.getLength(value) == 0; } else if (value instanceof CharSequence) { return ((CharSequence) value).length() == 0; } else if (value instanceof Number) { return isZero((Number) value); } return false; } }
Checker { @SuppressWarnings("rawtypes") public static boolean isFalsy(Object value) { if (value == null) { return true; } else if (value instanceof Boolean) { return !(Boolean) value; } else if (value instanceof Collection) { return ((Collection) value).isEmpty(); } else if (value instanceof Iterable) { return !((Iterable) value).iterator().hasNext(); } else if (value.getClass().isArray()) { return Array.getLength(value) == 0; } else if (value instanceof CharSequence) { return ((CharSequence) value).length() == 0; } else if (value instanceof Number) { return isZero((Number) value); } return false; } private  Checker(); }
Checker { @SuppressWarnings("rawtypes") public static boolean isFalsy(Object value) { if (value == null) { return true; } else if (value instanceof Boolean) { return !(Boolean) value; } else if (value instanceof Collection) { return ((Collection) value).isEmpty(); } else if (value instanceof Iterable) { return !((Iterable) value).iterator().hasNext(); } else if (value.getClass().isArray()) { return Array.getLength(value) == 0; } else if (value instanceof CharSequence) { return ((CharSequence) value).length() == 0; } else if (value instanceof Number) { return isZero((Number) value); } return false; } private  Checker(); static void checkArgument(boolean condition, String errorMessage); static void checkArgumentsNotNull(Object... arguments); static void checkArgumentNotNull(Object argument); static void checkArgumentNotEmpty(String argument); static boolean isNullOrEmpty(Collection<?> collection); static boolean isNullOrEmpty(Map<?, ?> map); @SuppressWarnings("rawtypes") static boolean isFalsy(Object value); }
Checker { @SuppressWarnings("rawtypes") public static boolean isFalsy(Object value) { if (value == null) { return true; } else if (value instanceof Boolean) { return !(Boolean) value; } else if (value instanceof Collection) { return ((Collection) value).isEmpty(); } else if (value instanceof Iterable) { return !((Iterable) value).iterator().hasNext(); } else if (value.getClass().isArray()) { return Array.getLength(value) == 0; } else if (value instanceof CharSequence) { return ((CharSequence) value).length() == 0; } else if (value instanceof Number) { return isZero((Number) value); } return false; } private  Checker(); static void checkArgument(boolean condition, String errorMessage); static void checkArgumentsNotNull(Object... arguments); static void checkArgumentNotNull(Object argument); static void checkArgumentNotEmpty(String argument); static boolean isNullOrEmpty(Collection<?> collection); static boolean isNullOrEmpty(Map<?, ?> map); @SuppressWarnings("rawtypes") static boolean isFalsy(Object value);  }