JavaGroovyEquivalents { public static boolean groovyTruth(Collection<?> c) { return c != null && !c.isEmpty(); }  static String join(Collection<?> collection, String separator); @SuppressWarnings("unchecked") static Collection<T> elvis(Collection<T> preferred, Collection<?> fallback); static String elvis(String preferred, String fallback); static String elvisString(Object preferred, Object fallback); @SuppressWarnings("unchecked") static T elvis(T preferred, T fallback); static T elvis(Iterable<?> preferences); @SuppressWarnings("unchecked") static T elvis(Object... preferences); static Object fix(Object o); static String asString(Object o); static String asNonnullString(Object o); static boolean groovyTruth(Collection<?> c); static boolean groovyTruth(String s); static boolean groovyTruth(Object o); static Predicate<T> groovyTruthPredicate(); static Function<Object,Boolean> groovyTruthFunction(); static Map<K,V> mapOf(K key1, V val1); @Deprecated static TimeDuration toTimeDuration(Object duration); @Deprecated static Predicate<T> toPredicate(final Closure<Boolean> c); @SuppressWarnings("unchecked") static Callable<T> toCallable(final Runnable job);  }
@Test public void testTruth() { assertFalse(groovyTruth((Object)null)); assertTrue(groovyTruth("someString")); assertFalse(groovyTruth("")); assertTrue(groovyTruth(1)); assertTrue(groovyTruth((byte)1)); assertTrue(groovyTruth((short)1)); assertTrue(groovyTruth(1L)); assertTrue(groovyTruth(1F)); assertTrue(groovyTruth(1D)); assertFalse(groovyTruth(0)); assertFalse(groovyTruth((byte)0)); assertFalse(groovyTruth((short)0)); assertFalse(groovyTruth(0L)); assertFalse(groovyTruth(0F)); assertFalse(groovyTruth(0D)); assertTrue(groovyTruth(true)); assertFalse(groovyTruth(false)); assertTrue(groovyTruth(gstring)); assertFalse(groovyTruth(emptyGstring)); }