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.github.lburgazzoli.examples.karaf.hz.cmd.HazelcastListCommand.java

@Override
public void execute() throws Exception {
    if (StringUtils.isNotBlank(arg)) {
        if (StringUtils.equalsIgnoreCase(HazelcastCommandConstants.LIST_MEMBERS, arg)) {
            doExecuteMemberList(getService().getInstance());
        } else if (StringUtils.equalsIgnoreCase(HazelcastCommandConstants.LIST_OBJECTS, arg)) {
            doExecuteDistributedObjectList(getService().getInstance());
        } else if (StringUtils.equalsIgnoreCase(HazelcastCommandConstants.LIST_PARTITIONS, arg)) {
            doExecutePartitionList(getService().getInstance());
        }//  ww w .  j a va 2  s.co m
    }
}

From source file:com.webbfontaine.valuewebb.irms.action.mail.MailActionHandler.java

private static boolean validate(MailActionDef actionDef) {
    return StringUtils.isNotBlank(actionDef.getMessage());
}

From source file:com.thinkbiganalytics.security.core.encrypt.EncryptionService.java

public String decrypt(String str) {
    if (StringUtils.isNotBlank(str)) {
        if (StringUtils.startsWith(str, CIPHER_PREFIX)) {
            str = StringUtils.removeStart(str, CIPHER_PREFIX);
        }/*from   w w w .  j av a  2 s .  c om*/
        return encryptor.decrypt(str);
    } else {
        return str;
    }
}

From source file:de.micromata.genome.gwiki.page.impl.wiki.filter.GWikiSpaceFilter.java

@Override
public Void filter(GWikiFilterChain<Void, GWikiServeElementFilterEvent, GWikiServeElementFilter> chain,
        GWikiServeElementFilterEvent event) {
    GWikiContext wikiContext = event.getWikiContext();
    String setspace = wikiContext.getRequestParameter(WIKI_SET_SPACE_PARAM);
    if (StringUtils.isNotBlank(setspace) == true) {
        String redid = wikiContext.getWikiWeb().getSpaces().switchUserSpace(wikiContext, setspace);
        if (redid != null) {
            try {
                wikiContext.getResponse().sendRedirect(wikiContext.localUrl(redid));
                return null;
                //          wikiContext.sendError(HttpServletResponse.SC_TEMPORARY_REDIRECT, redUrl);
            } catch (IOException ex) {
                ; // nothing
            }/*from   w  ww.  ja va 2s . c  o  m*/
        }
    } else {
        String spaceId = wikiContext.getWikiWeb().getSpaces().findCurrentPageSpaceId(wikiContext);
        if (spaceId != null && StringUtils.equals(spaceId, setspace) == false) {
            String redid = wikiContext.getWikiWeb().getSpaces().switchUserSpace(wikiContext, spaceId);
        }
    }
    chain.nextFilter(event);

    return null;
}

From source file:com.netflix.genie.web.data.repositories.jpa.specifications.JpaCommandSpecs.java

/**
 * Get a specification using the specified parameters.
 *
 * @param name     The name of the command
 * @param user     The name of the user who created the command
 * @param statuses The status of the command
 * @param tags     The set of tags to search the command for
 * @return A specification object used for querying
 *///from www  .  j a v a2s  .  c om
public static Specification<CommandEntity> find(@Nullable final String name, @Nullable final String user,
        @Nullable final Set<CommandStatus> statuses, @Nullable final Set<TagEntity> tags) {
    return (final Root<CommandEntity> root, final CriteriaQuery<?> cq, final CriteriaBuilder cb) -> {
        final List<Predicate> predicates = new ArrayList<>();
        if (StringUtils.isNotBlank(name)) {
            predicates.add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb,
                    root.get(CommandEntity_.name), name));
        }
        if (StringUtils.isNotBlank(user)) {
            predicates.add(JpaSpecificationUtils.getStringLikeOrEqualPredicate(cb,
                    root.get(CommandEntity_.user), user));
        }
        if (statuses != null && !statuses.isEmpty()) {
            predicates.add(
                    cb.or(statuses.stream().map(status -> cb.equal(root.get(CommandEntity_.status), status))
                            .toArray(Predicate[]::new)));
        }
        if (tags != null && !tags.isEmpty()) {
            final Join<CommandEntity, TagEntity> tagEntityJoin = root.join(CommandEntity_.tags);
            predicates.add(tagEntityJoin.in(tags));
            cq.groupBy(root.get(CommandEntity_.id));
            cq.having(cb.equal(cb.count(root.get(CommandEntity_.id)), tags.size()));
        }
        return cb.and(predicates.toArray(new Predicate[predicates.size()]));
    };
}

From source file:com.norconex.collector.core.checksum.impl.MD5DocumentChecksummerTest.java

@Test
public void testCreateDocumentChecksumFromContent() throws IOException {
    // Simply should not fail and return something.
    String content = "Some content";
    CachedInputStream is = new CachedStreamFactory(1024, 1024).newInputStream(content);
    ImporterDocument doc = new ImporterDocument("N/A", is);
    MD5DocumentChecksummer cs = new MD5DocumentChecksummer();
    String checksum = cs.createDocumentChecksum(doc);
    is.dispose();//from   w  w w. j a v  a  2s  . c o m
    Assert.assertTrue("No checksum was generated.", StringUtils.isNotBlank(checksum));
}

From source file:com.hbc.api.trade.order.OrderPal.java

/**
 * ??/*from w  ww.jav  a  2s .c o  m*/
 * @param orderStatus
 * @param guideId
 * @return
 */
public static boolean hasGuideInfo(Integer orderStatus, String guideId) {
    switch (OrderStatus.getStatus(orderStatus)) {
    case PAYSUCCESS:
        return StringUtils.isNotBlank(guideId) && !guideId.equals("0");
    case INITSTATE:
    case PAY_OUTTIME_CLOSE:
        return false;
    default:
        return true;
    }
}

From source file:com.aistor.common.servlet.ValidateCodeServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String validateCode = request.getParameter("validateCode"); // AJAX??true
    if (StringUtils.isNotBlank(validateCode)) {
        response.getOutputStream().print(validate(request, validateCode) ? "true" : "false");
    } else {//from w  w w  . ja va 2 s . c om
        this.doPost(request, response);
    }
}

From source file:com.github.achatain.nopasswordauthentication.utils.AuthorizedServlet.java

protected String extractApiToken(HttpServletRequest req) {
    String authorization = req.getHeader(HttpHeaders.AUTHORIZATION);
    Preconditions.checkArgument(authorization != null, "Missing authorization header");

    String apiToken = StringUtils.removeStartIgnoreCase(authorization, BEARER_PREFIX);
    Preconditions.checkArgument(StringUtils.isNotBlank(apiToken), "Missing api token");

    return StringUtils.trim(apiToken);
}

From source file:com.jxt.web.filter.agent.AgentFilterFactory.java

private boolean isNotBlank(String toAgent) {
    return StringUtils.isNotBlank(toAgent);
}