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

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

Introduction

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

Prototype

public static boolean isEmpty(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is empty ("") or null.

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

NOTE: This method changed in Lang version 2.0.

Usage

From source file:de.jcup.egradle.codeassist.UserInputProposalFilter.java

/**
 * Filter given proposals// w ww.j a  va 2 s .  co  m
 * 
 * @param proposals
 * @param entered
 *            relevant code, already entered by user
 * @return
 */
Set<Proposal> filterAndSetupProposals(Set<Proposal> proposals, String entered) {
    if (StringUtils.isEmpty(entered)) {
        /* no relavant code entered */
        return new LinkedHashSet<>(proposals);
    }
    String enteredLowerCased = entered.toLowerCase();
    Set<Proposal> filteredResult = new LinkedHashSet<>();
    for (Proposal proposal : proposals) {
        String label = proposal.getLabel();
        String codeLowerCased = label.toLowerCase();
        if (codeLowerCased.indexOf(enteredLowerCased) != -1) {
            filteredResult.add(proposal);
        }
    }
    return filteredResult;

}

From source file:com.controller.email.GetEmailTagsServlet.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//from w ww.  j  a va2s.  c  o m
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    List<Map<String, Object>> tagsFromMandrill = MandrillApiHandler.getTags();
    List<Map<String, Object>> tagsFromMandrillForUser = new ArrayList<>();

    HttpSession session = request.getSession();
    if (session.getAttribute("UID") == null || StringUtils.isEmpty(session.getAttribute("UID").toString())) {
        Map<String, String> responseMap = new HashMap<>();
        responseMap.put("error", "user is not logged in");
        response.getWriter().write(new Gson().toJson(responseMap));
        response.setStatus(HttpServletResponse.SC_FORBIDDEN);
        return;
    }
    int userId = Integer.parseInt(session.getAttribute("UID").toString());
    Set<String> tagsForUser = EmailHistoryDAO.getTagsForUser(userId);
    for (Map<String, Object> mTag : tagsFromMandrill) {
        if (mTag.get("tag") != null) {
            if (tagsForUser.contains(mTag.get("tag").toString())) {
                tagsFromMandrillForUser.add(mTag);
            }
        }
    }
    response.getWriter().write(new Gson().toJson(tagsFromMandrillForUser));

    response.getWriter().flush();
    response.setStatus(HttpServletResponse.SC_OK);
}

From source file:com.pinterest.teletraan.security.UserDataHelper.java

public UserDataHelper(String userDataUrl, String groupDataUrl, String tokenCacheSpec,
        TeletraanServiceContext context) {
    this.userDataUrl = userDataUrl;
    this.groupDataUrl = groupDataUrl;
    this.context = context;
    if (!StringUtils.isEmpty(tokenCacheSpec)) {
        tokenCache = CacheBuilder.from(tokenCacheSpec).build(new CacheLoader<String, UserSecurityContext>() {
            @Override//from w w w.  ja va  2s  . co  m
            public UserSecurityContext load(String token) throws Exception {
                return loadOauthUserData(token);
            }
        });
    }
}

From source file:de.micromata.genome.gwiki.model.matcher.GWikiChildMatcher.java

public boolean isChildOf(GWikiElementInfo first, GWikiElementInfo other, int curLevel) {
    if (curLevel > minLevel || curLevel < maxLevel) {
        return false;
    }// ww w  .  j  a  va 2  s  . c  o m
    if (first.getId().equals(other.getId()) == true) {
        return true;
    }
    if (StringUtils.isEmpty(first.getParentId()) == true) {
        return false;
    }
    GWikiElementInfo pei = wikiContext.getWikiWeb().findElementInfo(first.getParentId());
    if (pei == null) {
        return false;
    }
    return isChildOf(pei, other, ++curLevel);
}

From source file:android.databinding.compilationTest.SimpleCompilationTest.java

@Test
public void listTasks() throws IOException, URISyntaxException, InterruptedException {
    prepareProject();/* w ww .  j a  v a 2 s .c o m*/
    CompilationResult result = runGradle("tasks");
    assertEquals(0, result.resultCode);
    assertTrue("there should not be any errors", StringUtils.isEmpty(result.error));
    assertTrue("Test sanity, empty project tasks",
            result.resultContainsText("All tasks runnable from root project"));
}

From source file:com.netflix.spinnaker.clouddriver.artifacts.s3.S3ArtifactCredentials.java

protected AmazonS3 getS3Client() {
    AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard();

    if (!StringUtils.isEmpty(apiEndpoint)) {
        AwsClientBuilder.EndpointConfiguration endpoint = new AwsClientBuilder.EndpointConfiguration(
                apiEndpoint, apiRegion);
        builder.setEndpointConfiguration(endpoint);
        builder.setPathStyleAccessEnabled(true);
    } else if (!StringUtils.isEmpty(region)) {
        builder.setRegion(region);/*from   ww w .j a v a  2  s .  c o m*/
    }

    return builder.build();
}

From source file:com.t3.macro.api.functions.input.VarSpec.java

/** Create a VarSpec from a non-empty specifier string. */
public VarSpec(String specifier) throws SpecifierException, InputType.OptionException {
    String[] parts = (specifier).split("\\|");
    int numparts = parts.length;

    String name, value, prompt;// ww w  .  j  av a  2s .  c  om
    InputType inputType;

    name = (numparts > 0) ? parts[0].trim() : "";
    if (StringUtils.isEmpty(name))
        throw new SpecifierException(I18N.getText("macro.function.input.invalidSpecifier", specifier));

    value = (numparts > 1) ? parts[1].trim() : "";
    if (StringUtils.isEmpty(value))
        value = "0"; // Avoids having a default value of ""

    prompt = (numparts > 2) ? parts[2].trim() : "";
    if (StringUtils.isEmpty(prompt))
        prompt = name;

    String inputTypeStr = (numparts > 3) ? parts[3].trim() : "";
    inputType = InputType.inputTypeFromName(inputTypeStr);
    if (inputType == null) {
        if (StringUtils.isEmpty(inputTypeStr)) {
            inputType = InputType.TEXT; // default
        } else {
            throw new SpecifierException(
                    I18N.getText("macro.function.input.invalidType", inputTypeStr, specifier));
        }
    }

    String options = (numparts > 4) ? parts[4].trim() : "";

    initialize(name, value, prompt, inputType, options);
}

From source file:com.ankang.report.pool.AbstractReportAliasPool.java

protected final <T> boolean mount(String alias, T aliasClass) {
    if (StringUtils.isEmpty(alias)) {
        logger.error("alias can't be empty");
        return Boolean.FALSE;
    }// w  w  w.  ja v a  2  s . c  o  m
    if (null == waitMap) {
        logger.error("aliasClass can't be empty");
        return Boolean.FALSE;
    }
    synchronized (waitMap) {

        if (waitMap.containsKey(alias)) {
            logger.error("duplicate alias : " + alias);
            return Boolean.FALSE;
        }
        waitMap.put(alias, aliasClass);
        return Boolean.TRUE;
    }
}

From source file:io.wcm.devops.conga.generator.plugins.multiply.TenantMultiply.java

@Override
public List<Map<String, Object>> multiply(MultiplyContext context) {
    List<Map<String, Object>> contexts = new ArrayList<>();

    for (Tenant tenant : context.getEnvironment().getTenants()) {
        if (StringUtils.isEmpty(tenant.getTenant())) {
            throw new GeneratorException("Tenant without tenant name detected.");
        }//  www  .ja  v a 2 s. c  o  m
        if (acceptTenant(tenant, context.getRoleFile().getMultiplyOptions())) {
            Map<String, Object> mergedConfig = MapMerger.merge(tenant.getConfig(), context.getConfig());

            // set tenant-specific context variables
            mergedConfig.put(ContextProperties.TENANT, tenant.getTenant());
            mergedConfig.put(ContextProperties.TENANT_ROLES, tenant.getRoles());

            contexts.add(mergedConfig);
        }
    }

    return contexts;
}

From source file:com.bellman.bible.service.db.mynote.MyNoteDto.java

public boolean isEmpty() {
    return StringUtils.isEmpty(noteText);
}