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

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

Description

to String When Null Or Empty Or Space

Declaration

public static String toStringWhenNullOrEmptyOrSpace(Object src,
            String newValue) 

Method Source Code

//package com.java2s;

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

Related

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