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.hybris.mobile.app.commerce.activity.OrderHistoryActivity.java

@Override
protected void onResume() {
    super.onResume();

    Intent intent = getIntent();// ww w  . j ava  2  s . c o  m

    // Search query, we redirect to the order details page
    if (intent != null && StringUtils.isNotBlank(intent.getStringExtra(SearchManager.QUERY))) {
        Intent newIntent = new Intent(this, OrderDetailActivity.class);
        newIntent.putExtra(IntentConstants.ORDER_CODE, intent.getStringExtra(SearchManager.QUERY));
        newIntent.putExtra(IntentConstants.ORDER_FROM_SEARCH, true);
        startActivity(newIntent);
    }

}

From source file:com.netflix.genie.core.jpa.specifications.JpaApplicationSpecs.java

/**
 * Get a specification using the specified parameters.
 *
 * @param name     The name of the application
 * @param user     The name of the user who created the application
 * @param statuses The status of the application
 * @param tags     The set of tags to search the command for
 * @param type     The type of applications to fine
 * @return A specification object used for querying
 *///from w  ww  .j a v a  2 s.c  o  m
public static Specification<ApplicationEntity> find(final String name, final String user,
        final Set<ApplicationStatus> statuses, final Set<String> tags, final String type) {
    return (final Root<ApplicationEntity> root, final CriteriaQuery<?> cq, final CriteriaBuilder cb) -> {
        final List<Predicate> predicates = new ArrayList<>();
        if (StringUtils.isNotBlank(name)) {
            predicates.add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb,
                    root.get(ApplicationEntity_.name), name));
        }
        if (StringUtils.isNotBlank(user)) {
            predicates.add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb,
                    root.get(ApplicationEntity_.user), user));
        }
        if (statuses != null && !statuses.isEmpty()) {
            final List<Predicate> orPredicates = statuses.stream()
                    .map(status -> cb.equal(root.get(ApplicationEntity_.status), status))
                    .collect(Collectors.toList());
            predicates.add(cb.or(orPredicates.toArray(new Predicate[orPredicates.size()])));
        }
        if (tags != null && !tags.isEmpty()) {
            predicates.add(
                    cb.like(root.get(ApplicationEntity_.tags), JpaSpecificationUtils.getTagLikeString(tags)));
        }
        if (StringUtils.isNotBlank(type)) {
            predicates.add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb,
                    root.get(ApplicationEntity_.type), type));
        }
        return cb.and(predicates.toArray(new Predicate[predicates.size()]));
    };
}

From source file:co.runrightfast.core.utils.ConfigUtils.java

/**
 * if the path is a bad path expression, then false is returned
 *
 * @param config config/*from   ww  w  . j  a  v  a2  s.  c  o m*/
 * @param path base path
 * @param paths additional paths to be joined to the base path
 * @return if path exists
 */
static boolean hasPath(final Config config, final String path, final String... paths) {
    checkNotNull(config);
    checkArgument(StringUtils.isNotBlank(path));
    return config.hasPath(configPath(path, paths));
}

From source file:io.wcm.samples.handler.controller.resource.ResourceRichTextTest.java

@Test
public void testRichText() {
    context.currentResource("/content/handler/sample/en/jcr:content/content/contentrichtext");
    ResourceRichText underTest = context.request().adaptTo(ResourceRichText.class);
    assertTrue(underTest.isValid());/*  ww w.j a  va2  s . c  o  m*/
    assertTrue(StringUtils.isNotBlank(underTest.getMarkup()));
}

From source file:at.porscheinformatik.sonarqube.licensecheck.webservice.mavenlicense.MavenLicenseDeleteAction.java

@Override
public void handle(Request request, Response response) throws Exception {
    JsonReader jsonReader = Json.createReader(new StringReader(request.param(MavenLicenseConfiguration.PARAM)));
    JsonObject jsonObject = jsonReader.readObject();
    jsonReader.close();//  w  ww.  j  a va2  s  .  co m

    if (StringUtils.isNotBlank(jsonObject.getString(MavenLicenseConfiguration.PROPERTY_REGEX))) {
        mavenLicenseSettingsService
                .deleteMavenLicense(jsonObject.getString(MavenLicenseConfiguration.PROPERTY_REGEX));
        LOGGER.info(MavenLicenseConfiguration.INFO_DELETE_SUCCESS + jsonObject.toString());
        mavenLicenseSettingsService.sortMavenLicenses();
        response.stream().setStatus(HTTPConfiguration.HTTP_STATUS_OK);
    } else {
        LOGGER.error(MavenLicenseConfiguration.ERROR_DELETE_INVALID_INPUT + jsonObject.toString());
        response.stream().setStatus(HTTPConfiguration.HTTP_STATUS_NOT_MODIFIED);
    }
}

From source file:com.log4ic.compressor.cache.filter.BrowserCacheFilter.java

public void init(FilterConfig filterConfig) throws ServletException {
    if (filterConfig != null) {
        String ct = filterConfig.getInitParameter("cache-time");
        if (StringUtils.isNotBlank(ct)) {
            this.cacheTime = new Integer(ct);
        }/*from  w  w w. j  av a2s .  c o m*/
    }
}

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

@Override
public String getHtml(IMacroContext macroContext) {
    String body = StringUtils.defaultString(macroContext.getBody());

    String type = macroContext.getParameters();
    String typeClass = StringUtils.EMPTY;
    if (StringUtils.isNotBlank(type)) {
        typeClass = " alert-" + StringEscapeUtils.escapeHtml4(type); //$NON-NLS-1$
    }//from w  w  w  . j  av  a 2  s  .  c  om
    return "<div class=\"alert" + typeClass + "\">" + body + "</div>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}

From source file:com.vmware.photon.controller.common.thrift.ClientPoolUtils.java

public static <C extends TAsyncClient> C createNewClient(InetSocketAddress address,
        TProtocolFactory protocolFactory, ClientPoolOptions options, ThriftFactory thriftFactory,
        TAsyncClientFactory<C> clientFactory, Map<C, TTransport> clientTransportMap)
        throws IOException, TTransportException {
    TTransport socket = null;/*from   w  w  w  . ja v  a  2s  .c o m*/

    if (!isKeyStoreUsed(options.getKeyStorePath())) {
        // Auth is not enabled
        socket = new TNonblockingSocket(address.getHostString(), address.getPort());
    } else {
        TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters();
        params.setTrustStore(options.getKeyStorePath(), options.getKeyStorePassword());

        socket = TSSLTransportFactory.getClientSocket(address.getHostString(), address.getPort(),
                (options.getTimeoutMs() == 0L) ? 10000 : (int) options.getTimeoutMs(), params);
    }
    if (StringUtils.isNotBlank(options.getServiceName())) {
        protocolFactory = thriftFactory.create(options.getServiceName());
    }

    C client = clientFactory.create(protocolFactory, socket);
    clientTransportMap.put(client, socket);
    logger.debug("created new client {} for {}", client, address);
    return client;
}

From source file:com.iorga.iraj.util.QueryDSLUtils.java

public static JPAQuery addOrderBysOffsetAndLimit(JPAQuery jpaQuery, SearchScope searchScope,
        final Expression<?> baseExpression) {
    for (Entry<String, String> sortingEntry : searchScope.getSorting().entrySet()) {
        String path = sortingEntry.getKey();
        if (StringUtils.isNotBlank(path)) {
            jpaQuery.orderBy(parseOrderSpecifier(path, sortingEntry.getValue(), baseExpression));
        }//www  .  jav a  2s  .co  m
    }

    return jpaQuery.offset((searchScope.getCurrentPage() - 1) * searchScope.getCountPerPage())
            .limit(searchScope.getCountPerPage());
}

From source file:com.msopentech.odatajclient.engine.communication.request.retrieve.AbstractRetrieveRequestFactory.java

@Override
public ODataServiceDocumentRequest getServiceDocumentRequest(final String serviceRoot) {
    return new ODataServiceDocumentRequest(client,
            StringUtils.isNotBlank(serviceRoot) && serviceRoot.endsWith("/")
                    ? client.getURIBuilder(serviceRoot).build()
                    : client.getURIBuilder(serviceRoot + "/").build());
}