Java Utililty Methods Type Coalesce

List of utility methods to do Type Coalesce

Description

The list of methods to do Type Coalesce are organized into topic(s).

Method

Tcoalesce(T... args)
coalesce
if (args == null)
    return null;
for (T obj : args) {
    if (obj != null)
        return obj;
return null;
Tcoalesce(T... objects)
Returns the first object in the supplied list of objects that isn't null.
for (int i = 0; i < objects.length; i++)
    if (objects[i] != null)
        return objects[i];
return null;
Tcoalesce(T... objs)
Returns first non null object or null if all objects are null
for (T o : objs) {
    if (o != null) {
        return o;
return null;
Tcoalesce(T... tests)
Returns the first non-null value in the passed array
if (tests != null) {
    for (int i = 0; i < tests.length; i++) {
        if (notNull(tests[i])) {
            return tests[i];
return null;
...
Tcoalesce(T... ts)
coalesce
for (T t : ts) {
    if (t != null)
        return t;
return null;
Tcoalesce(T... values)
Returns the first non- null value among the given values .
return firstNonNull(values);
StringcoalesceString(String... objects)
coalesce String
for (int i = 0; i < objects.length; i++) {
    if (!isEmptyTrim(objects[i])) {
        return objects[i].trim();
return null;