Here you can find the source of coalesce(T... tests)
public static <T extends Object> T coalesce(T... tests)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w w w . j av a 2 s . co m*/ * Returns the first non-null value in the passed array */ public static <T extends Object> T coalesce(T... tests) { if (tests != null) { for (int i = 0; i < tests.length; i++) { if (notNull(tests[i])) { return tests[i]; } } } return null; } /** * Returns true if object is not null and not empty string */ public static boolean notNull(Object o) { return !isNull(o); } /** * Returns true if object is null or empty String */ public static boolean isNull(Object o) { return o == null || o.equals(""); } }