Here you can find the source of emptyStringToNull(String string)
null
, if the specified string is null
or the empty string.
Parameter | Description |
---|---|
string | the string |
null
if the specified string is null
or the empty string, the specified string otherwise
public static String emptyStringToNull(String string)
//package com.java2s; //License from project: Apache License public class Main { /**//from ww w . j a v a2 s .co m * Returns <code>null</code>, if the specified string is <code>null</code> or * the empty string. Returns the specified string otherwise. * @param string the string * @return <code>null</code> if the specified string is <code>null</code> or * the empty string, the specified string otherwise */ public static String emptyStringToNull(String string) { return isEmptyOrNull(string) ? null : string; } /** * Returns if the specified string is <code>null</code> or * the empty string. * @param string the string * @return <code>true</code> if the specified string is <code>null</code> or * the empty string, <code>false</code> otherwise */ public static boolean isEmptyOrNull(String string) { return (null == string) || (0 >= string.length()); } }