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.thoughtworks.go.config.rules.DirectiveType.java

public static Optional<DirectiveType> fromString(String directive) {
    if (StringUtils.isBlank(directive)) {
        return Optional.empty();
    }//  ww  w .  j av a  2 s .  c om

    switch (directive) {
    case "allow":
        return Optional.of(ALLOW);
    case "deny":
        return Optional.of(DENY);
    default:
        return Optional.empty();
    }
}

From source file:com.blacklocus.jres.strings.JresPaths.java

/**
 * @return fragments each appended with '/' if not present, and concatenated together
 *//*from   ww w  . j  a  v a 2  s.c om*/
public static String slashed(String... fragments) {
    StringBuilder sb = new StringBuilder();
    for (String fragment : fragments) {
        sb.append(StringUtils.isBlank(fragment) || fragment.endsWith("/") ? (fragment == null ? "" : fragment)
                : fragment + "/");
    }
    return sb.toString();
}

From source file:com.esri.geoevent.test.performance.report.ReportType.java

public static ReportType fromValue(String valueStr) {
    if (StringUtils.isBlank(valueStr))
        return UNKNOWN;
    if (CSV.toString().equalsIgnoreCase(valueStr))
        return CSV;
    else if (XLSX.toString().equalsIgnoreCase(valueStr))
        return XLSX;
    else if (XML.toString().equalsIgnoreCase(valueStr))
        return XML;
    else/* w  ww . ja v a2s  .  c o  m*/
        return UNKNOWN;
}

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

public static RunningStateType fromValue(String valueStr) {
    if (StringUtils.isBlank(valueStr))
        return UNKNOWN;
    else if (STARTING.toString().equalsIgnoreCase(valueStr))
        return STARTING;
    else if (STARTED.toString().equalsIgnoreCase(valueStr))
        return STARTED;
    else if (STOPPING.toString().equalsIgnoreCase(valueStr))
        return STOPPING;
    else if (STOPPED.toString().equalsIgnoreCase(valueStr))
        return STOPPED;
    else if (UNAVAILABLE.toString().equalsIgnoreCase(valueStr))
        return UNAVAILABLE;
    else if (ERROR.toString().equalsIgnoreCase(valueStr))
        return ERROR;
    else/* w w  w  .j a  va 2 s  .  c om*/
        return UNKNOWN;
}

From source file:com.dominion.salud.pedicom.negocio.configuration.DataSourceContextHolder.java

public static void setTargetDataSource(String targetDataSource) {
    if (StringUtils.isBlank(targetDataSource)) {
        throw new NullPointerException();
    }//from  w  ww  .  ja v a  2s  .c  om
    contextHolder.put("Bdactual", targetDataSource);
}

From source file:net.mamian.mySpringboot.utils.SecurityUtils.java

/**
 * ??/*from  ww w .j a va  2 s . c  o  m*/
 * Base64(now + identity)identitynull??
 *
 * @param identity can be null
 * @return
 */
public static String getSalt(String identity) {
    String now = df.format(new Date());
    String identityString = StringUtils.isBlank(identity) ? RandomStringUtils.randomAlphanumeric(20)
            : identity.trim();
    return Base64.encodeBase64String(blend(now, identityString));
}

From source file:com.jayway.restassured.internal.UriValidator.java

/**
 * Checks if the <code>potentialUri</code> is a URI.
 *
 * @param potentialUri The URI to check.
 * @return <code>true</code> if it is a URI, <code>false</code> otherwise.
 *///from  w ww .j ava  2s. co m
public static boolean isUri(String potentialUri) {
    if (StringUtils.isBlank(potentialUri)) {
        return false;
    }

    try {
        URI uri = new URI(potentialUri);
        return uri.getScheme() != null && uri.getHost() != null;
    } catch (URISyntaxException e) {
        return false;
    }
}

From source file:controllers.api.v1.SchemaHistory.java

public static Result getPagedDatasets() {
    ObjectNode result = Json.newObject();

    String name = request().getQueryString("name");
    int page = 1;
    String pageStr = request().getQueryString("page");
    if (StringUtils.isBlank(pageStr)) {
        page = 1;/*w w w.  j av  a  2s . c om*/
    } else {
        try {
            page = Integer.parseInt(pageStr);
        } catch (NumberFormatException e) {
            Logger.error("SchemaHistory Controller getPagedDatasets wrong page parameter. Error message: "
                    + e.getMessage());
            page = 1;
        }
    }

    Long datasetId = 0L;
    String datasetIdStr = request().getQueryString("datasetId");
    if (StringUtils.isNotBlank(datasetIdStr)) {
        try {
            datasetId = Long.parseLong(datasetIdStr);
        } catch (NumberFormatException e) {
            datasetId = 0L;
        }
    }

    int size = 10;
    String sizeStr = request().getQueryString("size");
    if (StringUtils.isBlank(sizeStr)) {
        size = 10;
    } else {
        try {
            size = Integer.parseInt(sizeStr);
        } catch (NumberFormatException e) {
            Logger.error("SchemaHistory Controller getPagedDatasets wrong size parameter. Error message: "
                    + e.getMessage());
            size = 10;
        }
    }

    result.put("status", "ok");
    result.set("data", SchemaHistoryDAO.getPagedSchemaDataset(name, datasetId, page, size));
    return ok(result);
}

From source file:com.nortal.petit.beanmapper.BeanMappingStringUtils.java

/**
 * Transforms the given camel case string into it's underscore
 * representation. Example: someString -&gt; some_string.
 * //  ww w .  jav a  2 s  . c  om
 * @param camelCase
 *            string in camel case.
 * @return string in underscore representation.
 */
public static String camelCaseToUnderscore(String camelCase) {
    if (StringUtils.isBlank(camelCase)) {
        return camelCase;
    }

    StringBuilder sb = new StringBuilder();

    for (Character c : camelCase.toCharArray()) {
        if (Character.isUpperCase(c)) {
            c = Character.toLowerCase(c);
            if (sb.length() > 0) {
                sb.append("_");
            }
        }

        sb.append(c);
    }

    return sb.toString();
}

From source file:ch.cyberduck.ui.browser.SearchFilterFactory.java

public static Filter<Path> create(final String input, final boolean hidden) {
    if (StringUtils.isBlank(input)) {
        // Revert to the last used default filter
        return create(hidden);
    } else {/* www  . j  a va2 s .  c  o m*/
        // Setting up a custom filter for the directory listing
        return new SearchFilter(input);
    }
}