Java Type Coalesce coalesce(Object... items)

Here you can find the source of coalesce(Object... items)

Description

Find first non-null and non-empty item

License

Open Source License

Parameter

Parameter Description
items a parameter

Return

First matched String or else empty string

Declaration

public static String coalesce(Object... items) 

Method Source Code

//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 "";
    }
}

Related

  1. coalesce(final T... objects)
  2. coalesce(final T... ts)
  3. coalesce(float... p)
  4. coalesce(Object src, Object defaultValue)
  5. coalesce(Object... args)
  6. coalesce(String str1, String str2)
  7. coalesce(String... strings)
  8. coalesce(String... strings)
  9. coalesce(String... vals)