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.labs64.netlicensing.domain.vo.Currency.java

/**
 * Parse currency value to {@link Currency} enum.
 *
 * @param value/* w ww  .j ava  2  s  .c o m*/
 *            currency value
 * @return {@link Currency} enum object or throws {@link IllegalArgumentException} if no corresponding
 *         {@link Currency} enum object found
 */
public static Currency parseValue(final String value) {
    for (final Currency currency : Currency.values()) {
        if (currency.value.equalsIgnoreCase(value)) {
            return currency;
        }
    }
    if (value != null && StringUtils.isBlank(value)) {
        return NONE;
    }
    throw new IllegalArgumentException(value);
}

From source file:net.gvmtool.api.Candidates.java

public Path get(Context context, String candidateName) {
    if (StringUtils.isBlank(candidateName)) {
        throw new IllegalArgumentException("No candidate name was provided");
    }//from   ww w .j av  a  2 s  .co  m

    return context.candidateDir(candidateName);
}

From source file:com.wyb.utils.util.PatternUtil.java

/**
 * ????//  w ww .j a v a2s  .  c o  m
 *
 * @param idCard ???15?18?????
 * @return ??true?false
 */
public static boolean isIdCard(String idCard) {
    if (StringUtils.isBlank(idCard)) {
        return false;
    }
    String regex = "[1-9]\\d{13,16}[a-zA-Z0-9]{1}";
    return Pattern.matches(regex, idCard);
}

From source file:io.kahu.hawaii.util.exception.ItemValidation.java

public ItemValidation(String key, HawaiiItemValidationError error) {
    assert (!StringUtils.isBlank(key) && error != null);
    this.key = key;
    this.error = error;
}

From source file:io.cloudslang.content.utils.BooleanUtilities.java

/**
 * Given a boolean in string format, it checks if it's 'true' or 'false' (case insensitive)
 *
 * @param booleanStr the string to check
 * @return true if booleanStr is 'true' or 'false' otherwise false
 *///  w w  w.  j a v  a 2  s. c  om
public static boolean isValid(@Nullable final String booleanStr) {
    if (StringUtils.isBlank(booleanStr)) {
        return false;
    }
    final String lowerCaseBoolean = getLowerCaseString(booleanStr);
    return lowerCaseBoolean.equals(BooleanValues.TRUE) || lowerCaseBoolean.equals(BooleanValues.FALSE);
}

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

public static File toFile(String dirAsString) {
    if (StringUtils.isBlank(dirAsString)) {
        return null;
    }//  ww  w .ja  v  a  2  s .c om

    // special case for ./some-dir
    if (dirAsString.charAt(0) == '.' && (dirAsString.charAt(1) == '\\' || dirAsString.charAt(1) == '/')) {
        return new File(dirAsString.substring(2));
    }
    return new File(dirAsString);
}

From source file:com.hbc.api.trade.bdata.common.util.ParameterValidator.java

/**
 * @param paramValue ??//from w  w  w .  j  a v  a  2  s .  co m
 * @param paramNameTip ????
 */
public static void validateParamString(String paramValue, String paramNameTip) {
    if (StringUtils.isBlank(paramValue)) {
        throw new ParamValidateException(CommonReturnCodeEnum.PARAM_ERROR_WITHARG, paramNameTip);
    }
}

From source file:ext.sns.auth.AccessTokenResponse.java

/**
 * ?AccessTokenResponse??responseStringnull
 * /*from   w w w . j a va  2s  . com*/
 * @param responseString 
 * @param responseType 
 * @return AccessTokenResponsenull - ??responseString
 */
public static AccessTokenResponse create(String responseString) {
    if (StringUtils.isBlank(responseString)) {
        return null;
    }

    AccessTokenResponse response = new AccessTokenResponse();
    response.setResultTypeByResponseStr(responseString);

    if (response.resultType == 1) {
        Map<String, String> responseMap = null;
        try {
            responseMap = parseResponseParam(responseString);
        } catch (RuntimeException e) {
            LOGGER.error("AccessTokenResponse?", e);
        }

        response.raw = responseString;
        response.accessToken = responseMap.get("access_token");

        String expiresInString = responseMap.get("expires_in");
        response.expiresIn = StringUtils.isNumeric(expiresInString) ? Long.valueOf(expiresInString) : null;

        response.refreshToken = responseMap.get("refresh_token");
        response.scope = responseMap.get("scope");
        response.tokenType = responseMap.get("token_type");

        response.resultObject = responseMap;
    } else if (response.resultType == 2) {
        JsonNode responseJSON = null;
        try {
            responseJSON = Json.parse(responseString);
        } catch (RuntimeException e) {
            LOGGER.error("AccessTokenResponse?", e);
        }

        response.raw = responseString;
        response.accessToken = responseJSON.has("access_token") ? responseJSON.get("access_token").asText()
                : null;

        String expiresInString = responseJSON.has("expires_in") ? responseJSON.get("expires_in").asText()
                : null;
        response.expiresIn = StringUtils.isNumeric(expiresInString) ? Long.valueOf(expiresInString) : null;

        response.refreshToken = responseJSON.has("refresh_token") ? responseJSON.get("refresh_token").asText()
                : null;
        response.scope = responseJSON.has("scope") ? responseJSON.get("scope").asText() : null;
        response.tokenType = responseJSON.has("token_type") ? responseJSON.get("token_type").asText() : null;

        response.resultObject = responseJSON;
    } else {
        return null;
    }

    return response;
}

From source file:com.trenako.validation.AddressValidator.java

private static boolean invalidStreetAddress(Address a) {
    return StringUtils.isBlank(a.getStreetAddress());
}

From source file:ch.cyberduck.core.DelimiterPathKindDetector.java

@Override
public Path.Type detect(final String path) {
    if (StringUtils.isBlank(path)) {
        return Path.Type.directory;
    }//from w  ww.  jav a 2s .  co  m
    if (path.endsWith(String.valueOf(Path.DELIMITER))) {
        return Path.Type.directory;
    }
    return Path.Type.file;
}