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

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

Introduction

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

Prototype

public static boolean isBlank(String str) 

Source Link

Document

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

Usage

From source file:adalid.core.NamedValueCache.java

public static NamedValue getInstance(String name) {
    if (StringUtils.isBlank(name)) {
        return null;
    }/*from w w w .  ja  va 2 s. co m*/
    NamedValue namedValue;
    if (cache.containsKey(name)) {
        namedValue = cache.get(name);
    } else {
        namedValue = new NamedValueCache(name);
        cache.put(name, namedValue);
    }
    return namedValue;
}

From source file:be.fedict.eid.pkira.portal.util.ExtraStringUtil.java

public static String blankAsNull(String s) {
    return StringUtils.isBlank(s) ? null : s;
}

From source file:net.sf.zekr.engine.search.SearchScopeItem.java

public static SearchScopeItem parse(String ssi) {
    if (StringUtils.isBlank(ssi)) {
        return null;
    }//from   www  .  jav a 2 s. c  om

    String[] s = StringUtils.split(ssi, "-");
    if (s.length < 4) {
        return null;
    } else {
        boolean exclusive = false;
        if (s.length >= 5) {
            exclusive = Boolean.parseBoolean(s[4]);
        }
        return new SearchScopeItem(Integer.parseInt(s[0]), Integer.parseInt(s[1]), Integer.parseInt(s[2]),
                Integer.parseInt(s[3]), exclusive);
    }
}

From source file:com.likethecolor.alchemy.api.validator.OutputDocumentValidator.java

public static void validate(final String jsonString) {
    if (StringUtils.isBlank(jsonString)) {
        throw new IllegalArgumentException("Output JSON cannot be null.");
    }//  w  w w  .ja va  2 s  .  c o  m
}

From source file:com.alibaba.ims.web.util.WebAssert.java

public static void notNull(Object... inputs) {
    if (inputs == null || inputs.length == 0) {
        return;// w  w  w . j a v  a2s .com
    }
    for (int i = 0; i < inputs.length; i++) {
        if (inputs[i] instanceof String) {
            if (StringUtils.isBlank((String) inputs[i])) {
                throw new WebException(ExceptionCode.Common.PARAM_ERROR);
            }
        } else {
            if (inputs[i] == null) {
                throw new WebException(ExceptionCode.Common.PARAM_ERROR);
            }
        }
    }
}

From source file:com.github.slugify.Slugify.java

public static String slugify(String input) {
    String ret = StringUtils.trim(input);
    if (StringUtils.isBlank(input)) {
        return "";
    }/*from   w w  w  . j a va2  s .  com*/

    ret = normalize(ret);
    ret = removeDuplicateWhiteSpaces(ret);
    return ret.replace(" ", "-").toLowerCase();
}

From source file:com.redhat.che.multitenant.UserCheTenantDataValidator.java

public static void validate(final UserCheTenantData data) {
    if (data == null) {
        LOG.error("'UserCheTenantData' can not be null");
        throw new NullPointerException("'UserCheTenantData' can not be null");
    } else if (StringUtils.isBlank(data.getClusterUrl())) {
        LOG.error("'ClusterUrl' can not be blank: {}", data);
        throw new IllegalArgumentException("'ClusterUrl' can not be blank");
    } else if (StringUtils.isBlank(data.getRouteBaseSuffix())) {
        LOG.error("'RouteBaseSuffix' can not be blank: {}", data);
        throw new IllegalArgumentException("'RouteBaseSuffix' can not be blank");
    } else if (StringUtils.isBlank(data.getNamespace())) {
        LOG.error("'Namespace' can not be blank: {}", data);
        throw new IllegalArgumentException("'Namespace' can not be blank");
    }/*from  w w  w  .j  a v  a  2 s .c  om*/
}

From source file:com.dodopal.common.enums.IdentityTypeEnum.java

public static IdentityTypeEnum getIdentityTypeByCode(String code) {
    if (StringUtils.isBlank(code)) {
        return null;
    }/*from   w ww  .  j av  a2 s. c o m*/
    return map.get(code);
}

From source file:com.safetys.framework.jmesa.util.AssertUtils.java

public static void notNull(String msg, Object obj) {
    if (obj == null) {
        throw new IllegalArgumentException(msg);
    }/*from ww  w.  ja v  a2  s  . co m*/

    if (obj instanceof String && StringUtils.isBlank(String.valueOf(obj))) {
        throw new IllegalArgumentException(msg);
    }
}

From source file:io.logspace.hq.rest.AbstractLogspaceResourcesBase.java

protected static int getQueryParam(Request request, String name, int defaultValue, int minValue, int maxValue) {
    String value = StringUtils.trim(request.queryParams(name));
    if (StringUtils.isBlank(value)) {
        return defaultValue;
    }/*w  ww .  j a v a2  s.  co m*/

    int result;
    try {
        result = Integer.parseInt(value);
    } catch (NumberFormatException e) {
        throw ParameterValueException.unparsableValue(name, value, e);
    }

    if (result < minValue) {
        throw ParameterValueException.valueTooSmall(name, result, minValue);
    }

    if (result > maxValue) {
        throw ParameterValueException.valueTooLarge(name, result, maxValue);
    }

    return result;
}