Here you can find the source of coalesce(Object... items)
Parameter | Description |
---|---|
items | a parameter |
public static String coalesce(Object... items)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w.ja v a 2 s . co m*/ * Find first non-null and non-empty item * @param items * @return First matched String or else empty string */ public static String coalesce(Object... items) { if (items == null) { return ""; } for (Object item : items) { if (item != null && ((String) item).length() > 0) { return item.toString(); } } return ""; } }