Android String Null Convert toStringWhenNullOrEmpty(Object src, String newValue)

Here you can find the source of toStringWhenNullOrEmpty(Object src, String newValue)

Description

to String When Null Or Empty

Declaration

public static String toStringWhenNullOrEmpty(Object src, String newValue) 

Method Source Code

//package com.java2s;

public class Main {
    public static String toStringWhenNullOrEmpty(Object src, String newValue) {
        if (src == null) {
            return newValue;
        }//  w w  w.j a v a 2 s .c o m
        String srcStr = src.toString();
        if ((srcStr == null) || (srcStr.equals(""))) {
            return newValue;
        }
        return srcStr;
    }
}

Related

  1. defaultIfNull(String str, String defaultStr)
  2. defaultIfBlank(String str, String defaultStr)
  3. defaultIfBlank(String str)
  4. isEmptyOrWhitespaceOnly(String str)
  5. toStringWhenNull(Object src, String newValue)
  6. toStringWhenNullOrEmptyOrSpace(Object src, String newValue)