Java String Empty to Null emptyToString(String str, String returnStr)

Here you can find the source of emptyToString(String str, String returnStr)

Description

empty To String

License

Open Source License

Declaration

public static String emptyToString(String str, String returnStr) 

Method Source Code

//package com.java2s;
/*/*from  w  ww.ja va  2  s .c  o m*/
 * Copyright (c) 2016 OpenDesign All rights reserved.
 *
 * This software is the confidential and proprietary information of OpenDesign.
 * You shall not disclose such Confidential Information and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with OpenDesign.
 */

public class Main {

    public static String emptyToString(String str, String returnStr) {
        return isNotEmpty(str) ? str : returnStr;
    }

    public static boolean isNotEmpty(String str) {
        return isNotNull(str) && !"".equals(str.trim());
    }

    public static boolean isNotNull(String str) {
        return str != null;
    }

    public static boolean equals(String str1, String str2) {
        return isNotNull(str1) ? str1.equals(str2) : false;
    }

    public static String equals(String str1, String str2, String returnStr) {
        return equals(str1, str2) ? returnStr : "";
    }
}

Related

  1. emptyToNull(String str)
  2. emptyToNull(String string)
  3. emptyToNull(String text)
  4. emptyToNull(String val)
  5. emptyToNull(String value)
  6. isHtmlNull(String str)
  7. nullSafeToString(Object obj)
  8. nvlStr(Object o, String valueIfNull)
  9. parseCommas(String s, boolean ignoreNulls)