Java String Empty to Null emptyToDefault(String value, String def)

Here you can find the source of emptyToDefault(String value, String def)

Description

empty To Default

License

Apache License

Declaration

public static String emptyToDefault(String value, String def) 

Method Source Code

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

public class Main {

    public static String emptyToDefault(String value, String def) {
        return (value == null || value.length() == 0) ? def : value;
    }//from w  ww . ja  va  2  s .com
}

Related

  1. emptyStringToNull(String input)
  2. emptyStringToNull(String str)
  3. emptyStringToNull(String string)
  4. emptyToDefault(T[] values, T[] def)
  5. emptyToNull(final String text, final boolean doTrim)
  6. emptyToNull(String field)
  7. emptyToNull(String s)