Example usage for org.apache.commons.lang3 StringUtils isBlank

List of usage examples for org.apache.commons.lang3 StringUtils isBlank

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils isBlank.

Prototype

public static boolean isBlank(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is whitespace, empty ("") or null.

 StringUtils.isBlank(null)      = true StringUtils.isBlank("")        = true StringUtils.isBlank(" ")       = true StringUtils.isBlank("bob")     = false StringUtils.isBlank("  bob  ") = false 

Usage

From source file:com.mirth.connect.util.CharsetUtils.java

/**
 * If the specified charset encoding equals DEFAULT_ENCODING or is
 * NULL/empty, then the specified default encoding will be returned. If the
 * specified default encoding is also NULL/empty then the default charset on
 * the server is returned.//from   w w  w  .  j a v a 2 s  . c o  m
 * 
 * @param charsetEncoding
 * @param defaultEncoding
 * @return
 */
public static String getEncoding(String charsetEncoding, String defaultEncoding) {
    if (StringUtils.equals(charsetEncoding, DEFAULT_ENCODING) || StringUtils.isBlank(charsetEncoding)) {
        if (StringUtils.isNotBlank(defaultEncoding)) {
            return defaultEncoding;
        } else {
            return Charset.defaultCharset().name();
        }
    } else {
        return charsetEncoding;
    }
}

From source file:aiai.ai.utils.EnvProperty.java

public static String strIfBlankThenNull(String prop) {
    if (StringUtils.isBlank(prop)) {
        return null;
    }//ww  w  .  ja  v a  2s .  c o m
    return prop;
}

From source file:com.ctrip.infosec.rule.resource.TongDun.java

/**
 * ?ip??/*from   w w w.ja  va 2  s .  c o  m*/
 *
 * @param ip
 * @param mobile
 * @return
 * {"reason_code":null,"final_decision":"Accept","seq_id":"1442309654522-72705995","final_score":0,"success":true}
 */
public static Map<String, Object> queryRegEvent(String ip, String mobile) {
    if (StringUtils.isBlank(ip) && StringUtils.isBlank(mobile)) {
        return Collections.EMPTY_MAP;
    }
    Map<String, Object> params = new HashMap<>();
    params.put("account_mobile", mobile);
    params.put("ip_address", ip);
    return DataProxy.queryForMap(serviceName, operationName_reg, params);
}

From source file:com.esri.geoevent.test.performance.ResponseType.java

public static ResponseType fromValue(String valueStr) {
    if (StringUtils.isBlank(valueStr))
        return UNKNOWN;
    else if (OK.toString().equalsIgnoreCase(valueStr))
        return OK;
    else if (STATE_CHANGED.toString().equalsIgnoreCase(valueStr))
        return STATE_CHANGED;
    else if (ERROR.toString().equalsIgnoreCase(valueStr))
        return ERROR;
    else// w w w  .  ja v a2  s  .  c  o m
        return UNKNOWN;
}

From source file:net.packet.State.java

public static State fromValue(String value) {
    if (StringUtils.isBlank(value)) {
        throw new IllegalArgumentException("Value cannot be null or empty!");
    }// w  w w.j  a  va 2 s  .c  om

    for (State s : State.values()) {
        if (value.equalsIgnoreCase(s.value)) {
            return s;
        }
    }

    throw new IllegalArgumentException("Cannot create enum from " + value + " value!");
}

From source file:com.esri.geoevent.test.performance.Mode.java

public static Mode fromValue(String valueStr) {
    if (StringUtils.isBlank(valueStr))
        return Unknown;
    if (Consumer.toString().equalsIgnoreCase(valueStr))
        return Consumer;
    else if (Producer.toString().equalsIgnoreCase(valueStr))
        return Producer;
    else if (Orchestrator.toString().equalsIgnoreCase(valueStr))
        return Orchestrator;
    else/*from w  ww  .  ja  va2 s  .co m*/
        return Unknown;
}

From source file:com.labs64.netlicensing.domain.vo.PaymentMethodEnum.java

public static PaymentMethodEnum parseString(final String paymentMethod) {
    if (StringUtils.isBlank(paymentMethod)) {
        return null;
    }//w  ww .  j a  va 2 s. c  o  m

    try {
        return PaymentMethodEnum.valueOf(paymentMethod);
    } catch (IllegalArgumentException e) {
        return null;
    }
}

From source file:net.packet.ActionType.java

public static ActionType fromValue(String value) {
    if (StringUtils.isBlank(value)) {
        throw new IllegalArgumentException("Value cannot be null or empty!");
    }/*from   w ww  .ja  v  a 2 s  .com*/

    for (ActionType at : ActionType.values()) {
        if (value.equalsIgnoreCase(at.value)) {
            return at;
        }
    }

    throw new IllegalArgumentException("Cannot create enum from " + value + " value!");
}

From source file:com.hbc.api.trade.order.controller.validator.OrderValidator.java

public static void validateOrderNo(String orderNo) {
    if (StringUtils.isBlank(orderNo)) {
        logger.error("orderNo null??orderNo=" + orderNo);
        throw new TradeException(TradeReturnCodeEnum.ORDER_PARAM_FAILED, "orderNo");
    }/*from  w ww  .j a v  a2 s . co m*/
}

From source file:edu.purdue.cybercenter.dm.util.JsonTransformer.java

public static String transformJson(String jsonIn) {
    if (StringUtils.isBlank(jsonIn)) {
        return "";
    }/*from w  ww .  j  a v a2  s . c  o m*/
    String trimmedJsonIn = jsonIn.trim();
    Map<String, Object> jsonObject;
    if (trimmedJsonIn.startsWith("{")) {
        try {
            jsonObject = Helper.deserialize(jsonIn, Map.class);
        } catch (Exception ex) {
            return jsonIn;
        }
    } else {
        return jsonIn;
    }
    Object directive = jsonObject.get(JsonTransformer.JSON_DIRECTIVE);
    if (directive == null) {
        return jsonIn;
    }
    Object data = jsonObject.get(JsonTransformer.JSON_DATA);
    if (data == null) {
        // return emoty string if there's no data
        return "";
    }
    Map<String, Object> context = (Map<String, Object>) jsonObject.get(JsonTransformer.JSON_CONTEXT);
    if (directive instanceof Map) {
        data = applyDirective((Map<String, Object>) directive, data, context);
    } else if (directive instanceof List) {
        List<Map<String, Object>> directives = (List) directive;
        for (Map<String, Object> d : directives) {
            data = applyDirective(d, data, context);
        }
    } else {
        throw new RuntimeException("Invalid directive oin json: " + jsonIn);
    }
    String jsonOut = Helper.deepSerialize(data);
    return jsonOut;
}