@Test public void testIsFalsy() { assertTrue(Booleans.isFalsy(null)); assertTrue(Booleans.isFalsy(false)); assertTrue(Booleans.isFalsy("")); assertTrue(Booleans.isFalsy(new StringBuffer())); assertTrue(Booleans.isFalsy(0f)); assertTrue(Booleans.isFalsy(0)); assertTrue(Booleans.isFalsy(0.0)); assertTrue(Booleans.isFalsy(new BigDecimal("0.0"))); assertTrue(Booleans.isFalsy(new BigInteger("0"))); assertTrue(Booleans.isFalsy(new ArrayList<>())); assertTrue(Booleans.isFalsy(new HashSet<>())); assertTrue(Booleans.isFalsy(new HashMap<>())); assertTrue(Booleans.isFalsy(new String[0])); assertTrue(Booleans.isFalsy(new AtomicLong(0))); assertTrue(Booleans.isFalsy(new AtomicBoolean(false))); assertFalse(Booleans.isFalsy(new Object())); assertFalse(Booleans.isFalsy(true)); assertFalse(Booleans.isFalsy("foo")); assertFalse(Booleans.isFalsy(new StringBuffer().append("foo"))); assertFalse(Booleans.isFalsy(1f)); assertFalse(Booleans.isFalsy(4)); assertFalse(Booleans.isFalsy(0.2)); assertFalse(Booleans.isFalsy(new BigDecimal("0.1"))); assertFalse(Booleans.isFalsy(new BigInteger("10"))); assertFalse(Booleans.isFalsy(Collections.singletonList("foo"))); assertFalse(Booleans.isFalsy(Collections.singletonMap("foo", "bar"))); assertFalse(Booleans.isFalsy(new String[] { "foo" })); assertFalse(Booleans.isFalsy(new AtomicLong(10))); assertFalse(Booleans.isFalsy(new AtomicBoolean(true))); }
public static boolean isFalsy(Object value) { if (value == null || Results.Result.NOT_FOUND.equals(value)) { return true; } else if (value instanceof Boolean) { return !(Boolean) value; } else if (value instanceof AtomicBoolean) { return !((AtomicBoolean) value).get(); } else if (value instanceof Collection) { return ((Collection<?>) value).isEmpty(); } else if (value instanceof Map) { return ((Map<?, ?>) value).isEmpty(); } 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; }
Booleans { public static boolean isFalsy(Object value) { if (value == null || Results.Result.NOT_FOUND.equals(value)) { return true; } else if (value instanceof Boolean) { return !(Boolean) value; } else if (value instanceof AtomicBoolean) { return !((AtomicBoolean) value).get(); } else if (value instanceof Collection) { return ((Collection<?>) value).isEmpty(); } else if (value instanceof Map) { return ((Map<?, ?>) value).isEmpty(); } 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; } }
Booleans { public static boolean isFalsy(Object value) { if (value == null || Results.Result.NOT_FOUND.equals(value)) { return true; } else if (value instanceof Boolean) { return !(Boolean) value; } else if (value instanceof AtomicBoolean) { return !((AtomicBoolean) value).get(); } else if (value instanceof Collection) { return ((Collection<?>) value).isEmpty(); } else if (value instanceof Map) { return ((Map<?, ?>) value).isEmpty(); } 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  Booleans(); }
Booleans { public static boolean isFalsy(Object value) { if (value == null || Results.Result.NOT_FOUND.equals(value)) { return true; } else if (value instanceof Boolean) { return !(Boolean) value; } else if (value instanceof AtomicBoolean) { return !((AtomicBoolean) value).get(); } else if (value instanceof Collection) { return ((Collection<?>) value).isEmpty(); } else if (value instanceof Map) { return ((Map<?, ?>) value).isEmpty(); } 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  Booleans(); static boolean isFalsy(Object value); }
Booleans { public static boolean isFalsy(Object value) { if (value == null || Results.Result.NOT_FOUND.equals(value)) { return true; } else if (value instanceof Boolean) { return !(Boolean) value; } else if (value instanceof AtomicBoolean) { return !((AtomicBoolean) value).get(); } else if (value instanceof Collection) { return ((Collection<?>) value).isEmpty(); } else if (value instanceof Map) { return ((Map<?, ?>) value).isEmpty(); } 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  Booleans(); static boolean isFalsy(Object value);  }