Here you can find the source of coalesce(String... strings)
public static String coalesce(String... strings)
//package com.java2s; /**// w ww .j a v a2 s . co m * Copyright 2015 Jan Lolling jan.lolling@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * returns the first not empty string * * {Category} StringUtil * * {talendTypes} String * * {param} string("testMe1","testMe2") strings: String. * * {example} coalesce(" test","hans"," TEST ","Tata") # "test" */ public static String coalesce(String... strings) { for (String s : strings) { if (s != null) { s = s.trim(); if (isEmpty(s) == false) { return s; } } } return null; } /** * returns true if the string is not filled or contains "null" * * {Category} StringUtil * * {talendTypes} String * * {param} object("value1") strings: String. * * {example} isEmpty(aString) # 2323133_18 */ public static boolean isEmpty(String s) { if (s == null) { return true; } if (s.trim().isEmpty()) { return true; } if (s.trim().equalsIgnoreCase("null")) { return true; } return false; } }