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

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

Introduction

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

Prototype

public static boolean isNotBlank(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is not empty (""), not null and not whitespace only.

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

Usage

From source file:com.norconex.jefmon.model.JobSuiteFactoryConfig.java

public boolean hasNonBlankProperties() {
    for (String value : properties.values()) {
        if (StringUtils.isNotBlank(value)) {
            return true;
        }// w  w w  .ja v a  2  s  .  c o m
    }
    return false;
}

From source file:com.netflix.genie.common.util.JsonUtils.java

/**
 * Convert a JSON string of a collection back to a Java object.
 *
 * @param source        The JSON string/*from w  ww.j ava 2  s. c om*/
 * @param typeReference The type reference of the collection to unmarshall to
 * @param <T>           The type of the collection ie Set of String
 * @return The Java object
 * @throws GenieException For any exception during unmarshalling
 */
public static <T extends Collection> T unmarshall(final String source, final TypeReference<T> typeReference)
        throws GenieException {
    try {
        final ObjectMapper mapper = new ObjectMapper();
        if (StringUtils.isNotBlank(source)) {
            return mapper.readValue(source, typeReference);
        } else {
            return mapper.readValue("[]", typeReference);
        }
    } catch (final IOException ioe) {
        throw new GenieServerException(ioe);
    }
}

From source file:co.runrightfast.vertx.core.RunRightFastVerticleMetrics.java

static String metricName(@NonNull final MetricType metricType, final String name, final String... names) {
    checkArgument(StringUtils.isNotBlank(name));
    if (names != null) {
        checkArgument(!Arrays.stream(names).filter(StringUtils::isBlank).findFirst().isPresent(),
                "any of the names cannot be blank");
    }/*from www.  j av a2  s  . co m*/
    final StringBuilder sb = new StringBuilder(64);
    sb.append(metricType.name()).append('.').append(name);
    Arrays.stream(names).forEach(n -> sb.append('.').append(n));
    return sb.toString();
}

From source file:com.nike.vault.client.DefaultVaultUrlResolver.java

/**
 * Attempts to acquire the Vault URL from the following places:
 * <ul>/*w  w w  . jav  a  2s  .c o  m*/
 * <li>Environment Variable - <code>VAULT_ADDR</code></li>
 * <li>Java System Property - <code>vault.addr</code></li>
 * </ul>
 *
 * @throws VaultClientException If unable to resolve the URL
 * @return Vault URL
 */
@Override
public String resolve() {
    final String envUrl = System.getenv(VAULT_ADDR_ENV_PROPERTY);
    final String sysUrl = System.getProperty(VAULT_ADDR_SYS_PROPERTY);

    if (StringUtils.isNotBlank(envUrl) && HttpUrl.parse(envUrl) != null) {
        return envUrl;
    } else if (StringUtils.isNotBlank(sysUrl) && HttpUrl.parse(sysUrl) != null) {
        return sysUrl;
    }

    throw new VaultClientException(
            "Failed to resolve the Vault URL from the environment and/or system properties.");
}

From source file:com.marand.thinkmed.api.externals.data.object.ExternalIdentityDto.java

public ExternalIdentityDto(final String id) {
    this.id = Preconditions.checkNotNull(id);
    Preconditions.checkArgument(StringUtils.isNotBlank(id));
}

From source file:de.blizzy.documentr.markdown.macro.impl.TabMacro.java

@Override
public String getHtml(IMacroContext macroContext) {
    String title = macroContext.getParameters();
    if (StringUtils.isNotBlank(title)) {
        TabData tabData = new TabData(title, macroContext.getBody());
        return TAB_START_MARKER + tabData.serialize() + TAB_END_MARKER;
    }//  w  w w.j  av a  2s .co m
    return null;
}

From source file:controllers.ExpertApp.java

@Transactional(readOnly = true)
public static Result search() {
    User user = User.getFromSession(session());
    DynamicForm requestData = Form.form().bindFromRequest();
    String p = requestData.get("p") == null ? "1|1" : requestData.get("p");
    String type = requestData.get("type") == null ? "html" : requestData.get("type");
    String ft = requestData.get("ft") == null ? "" : requestData.get("ft").trim();
    String cf = requestData.get("cf");
    String ssf = requestData.get("ssf");
    String ef = requestData.get("ef");
    String gf = requestData.get("gf");
    String o = requestData.get("o");
    String ot = requestData.get("ot");
    ScriptEngine engine = SemUtils.getEngine();
    try {//from w  w  w .  ja v  a2s .  co m
        if (StringUtils.isNotBlank(ft))
            ft = engine.eval("decodeURIComponent('" + ft + "')").toString();
        if (StringUtils.isNotBlank(cf))
            cf = engine.eval("decodeURIComponent('" + cf + "')").toString();
    } catch (ScriptException e) {
        e.printStackTrace();
    }
    Transformer trf = new Transformer(ft, p, cf, ssf, ef, gf, o, ot);
    String resultJson = SearchHttpClient.advancedQuery(trf.tranAdSearchNVP(Constants.HOME_EXPERT_PAGE_SIZE));
    EPage<ExpertListVO> pageObj = null;
    if (StringUtils.isNotBlank(resultJson))
        pageObj = trf.pageFromJson(resultJson, user, Constants.HOME_EXPERT_PAGE_SIZE);
    else
        pageObj = new EPage(null, 0L, 1, 1);

    pageObj.setCf(cf);
    pageObj.setEf(ef);
    pageObj.setFt(ft);
    pageObj.setGf(gf);
    pageObj.setO(o);
    pageObj.setOt(ot);
    pageObj.setSsf(ssf);

    List<String> countryList = SkillTag.getCountryNameWithCache();
    pageObj.setCountryList(countryList);

    if (!type.equals("json")) {
        return ok(views.html.expert.search.render(pageObj));
    } else {
        return ok(play.libs.Json.toJson(pageObj));
    }
}

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

private void help(final String page) {
    final StringBuilder site = new StringBuilder(PreferencesFactory.get().getProperty("website.help"));
    if (StringUtils.isNotBlank(page)) {
        site.append("/").append(page);
    }//  w ww. j a  va  2 s.  co m
    launcher.open(site.toString());
}

From source file:com.connio.sdk.request.user.UserReadRequest.java

@Override
protected Request request() {
    final Map<String, String> filter = new HashMap<>();

    if (StringUtils.isNotBlank(email))
        filter.put("email", email);

    filter.putAll(getPaginationParameters());

    return Request.get("accounts", filter);
}

From source file:edu.usu.sdl.openstorefront.core.sort.AttributeCodeArchComparator.java

@Override
public int compare(T o1, T o2) {
    //Codes should be numbers (Note the description includes the code so they should be sort as well)
    BigDecimal codeKey1;/*from   w ww  .  j ava 2  s.c  o  m*/
    BigDecimal codeKey2;

    if (o1.getSortOrder() != null && o2.getSortOrder() != null) {
        return o1.getSortOrder().compareTo(o2.getSortOrder());
    } else {
        if (StringUtils.isNotBlank(o1.getArchitectureCode())) {
            codeKey1 = StringProcessor.archtecureCodeToDecimal(o1.getArchitectureCode());
        } else {
            codeKey1 = StringProcessor.archtecureCodeToDecimal(o1.getAttributeCodePk().getAttributeCode());
        }

        if (StringUtils.isNotBlank(o2.getArchitectureCode())) {
            codeKey2 = StringProcessor.archtecureCodeToDecimal(o2.getArchitectureCode());
        } else {
            codeKey2 = StringProcessor.archtecureCodeToDecimal(o2.getAttributeCodePk().getAttributeCode());
        }

        int results = codeKey1.compareTo(codeKey2);
        if (results != 0) {
            return results;
        } else {
            return o1.getAttributeCodePk().getAttributeCode()
                    .compareTo(o2.getAttributeCodePk().getAttributeCode());
        }
    }
}