Use truthy falsy booleans in Java

Some scripting languages such as PHP, JavaScript, and Groovy allow the use of object reference in a conditional context. They have a standard boolean coercion for certain objects or references, “truthy” and “falsy” values. Could this be useful in Java?

In Java we have to directly access a property or invoke a method to create a boolean value. In some scripting languages, an array is false if it is null or empty. This simplifies the use of scripting and reduces the syntactic clutter. Of course, this also can introduce very subtle issues for the unwary.

Some possible method names are: true(), false(), truth(), valid(), asBoolean(), and so forth. I used “valid”, since it is not really about truth, but about whether a value is ready for use.

One truthy and falsy list for Java could be:

Object: false if null

Collection: false if empty or null

Maps: false if empty or null

Boolean: false if false

Iterators: false if there are no further elements

Strings: non-empty are true

Numbers: non-zero are true

Float: non-null are true

Implementation
Below is a simplistic implementation of a Truth class that provides truthy support in Java. A full implementation would have to take into account a lot of things, such as wrapped objects, multidimensional arrays, and so forth.
Example use:

Unfortunately in the implementation below, the test for null and the object’s condition, such as whether a list is empty, mixes two very different object states. Thus, in certain situations, further tests are required, or the idiomatic Java coding style retained.