Java Type Coalesce coalesceString(String... objects)

Here you can find the source of coalesceString(String... objects)

Description

coalesce String

License

Apache License

Declaration

public static String coalesceString(String... objects) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String coalesceString(String... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (!isEmptyTrim(objects[i])) {
                return objects[i].trim();
            }//from   w ww .j  a va  2 s  .  com
        }
        return null;
    }

    public static boolean isEmptyTrim(String valore) {
        return (valore == null || valore.trim().equals(""));
    }

    /**
     * Restiutisce la stringa s senza spazi iniziali e finali
     * Se s e' null o stringa vuota, restituisce una stringa di lunghezza 0
     */
    public static String trim(String s) {
        return s == null || s.trim().equals("") ? "" : s.trim();
    }
}

Related

  1. coalesce(T... objects)
  2. coalesce(T... objs)
  3. coalesce(T... tests)
  4. coalesce(T... ts)
  5. coalesce(T... values)