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

Stringcoalesce(Object... items)
Find first non-null and non-empty item
if (items == null) {
    return "";
for (Object item : items) {
    if (item != null && ((String) item).length() > 0) {
        return item.toString();
return "";
Stringcoalesce(String str1, String str2)
coalesce
if (str1 != null)
    return str1;
return str2;
Stringcoalesce(String... strings)
returns the first not empty string {Category} StringUtil {talendTypes} String {param} string("testMe1","testMe2") strings: String.
for (String s : strings) {
    if (s != null) {
        s = s.trim();
        if (isEmpty(s) == false) {
            return s;
return null;
Stringcoalesce(String... strings)
Same as the SQL COALESCE.
for (String s : strings) {
    if (!isEmpty(s)) {
        return s;
return "";
Stringcoalesce(String... vals)
Returns the first non-null value in the arguments.
for (String str : vals) {
    if (str != null)
        return str;
return null;
Stringcoalesce(String[] values)
Returns first not null && not empty String from String[]
for (String val : values)
    if (checkLen(val))
        return val;
return null;
Tcoalesce(T a, T b)
Return the first not null objects in the list of arguments
return a == null ? b : a;
Tcoalesce(T o0, T o1)
coalesce
return o0 != null ? o0 : o1;
Tcoalesce(T preferred, T alternative)
Checks whether a preferred value is valid and returns an alternative value if not.
return (preferred != null ? preferred : alternative);
Tcoalesce(T value, T whenNullValue)
Devuelve el mismo valor que se pasa en value salvo si es null, en cuyo caso se devuelve whenNullValue.
return value != null ? value : whenNullValue;