Example usage for org.springframework.util CollectionUtils isEmpty

List of usage examples for org.springframework.util CollectionUtils isEmpty

Introduction

In this page you can find the example usage for org.springframework.util CollectionUtils isEmpty.

Prototype

public static boolean isEmpty(@Nullable Map<?, ?> map) 

Source Link

Document

Return true if the supplied Map is null or empty.

Usage

From source file:com.capitalone.dashboard.collector.TeamDataClient.java

/**
 * Removes scope-owners (teams) from the collection which have went to an
 * non-active state//w ww . j  av  a  2 s .com
 *
 * @param teamId
 *            A given Team ID that went inactive and should be removed from
 *            the data collection
 */

private void removeInactiveScopeOwnerByTeamId(String teamId) {
    if (!StringUtils.isEmpty(teamId) && !CollectionUtils.isEmpty(teamRepo.getTeamIdById(teamId))) {
        ObjectId inactiveTeamId = teamRepo.getTeamIdById(teamId).get(0).getId();
        if (inactiveTeamId != null) {
            teamRepo.delete(inactiveTeamId);
        }
    }
}

From source file:at.pagu.soldockr.core.QueryParser.java

private void appendGroupByFields(SolrQuery solrQuery, List<Field> fields) {
    if (CollectionUtils.isEmpty(fields)) {
        return;//from   ww w  .  j a  v  a  2s  .com
    }

    if (fields.size() > 1) {
        // there is a bug in solj which prevents multiple grouping
        // although available via HTTP call
        throw new ApiUsageException(
                "Cannot group on more than one field with current SolrJ API. Group on single field insead");
    }

    solrQuery.set(GroupParams.GROUP, true);
    solrQuery.setParam(GroupParams.GROUP_MAIN, true);

    for (Field field : fields) {
        solrQuery.add(GroupParams.GROUP_FIELD, field.getName());
    }
}

From source file:com.sra.biotech.submittool.persistence.service.SubmissionServiceImpl.java

public List<Submission> findByStatus(String status) {

    SubmissionResources resources = restTemplate.getForObject(
            getSubmissionUrlTemplate() + "/search/findByStatus/?status={status}", SubmissionResources.class,
            status);//from   w  w  w.  j  ava2  s  .  co  m

    if (resources == null || CollectionUtils.isEmpty(resources.getContent())) {
        return Collections.emptyList();
    }

    Link listSelfLink = resources.getLink(Link.REL_SELF);
    Collection<SubmissionResource> content = resources.getContent();

    if (!content.isEmpty()) {
        SubmissionResource firstSubmissionResource = content.iterator().next();
        Link linkToFirstResource = firstSubmissionResource.getLink(Link.REL_SELF);
        System.out.println("href = " + linkToFirstResource.getHref());
        System.out.println("rel = " + linkToFirstResource.getRel());
    }

    return resources.unwrap();
}

From source file:com.hs.mail.imap.processor.fetch.EnvelopeBuilder.java

private Address buildAddress(Mailbox mailbox) {
    // Javamail raises exception when personal name is surrounded with
    // double quotation mark.
    String name = StringUtils.strip(mailbox.getName(), "\"");
    String domain = mailbox.getDomain();
    DomainList route = mailbox.getRoute();
    String atDomainList;//from w w  w .j  a va  2s. c  o  m
    if (CollectionUtils.isEmpty(route)) {
        atDomainList = null;
    } else {
        atDomainList = route.toRouteString();
    }
    String localPart = mailbox.getLocalPart();
    return new Address(atDomainList, domain, localPart, name);
}

From source file:com.ruzhi.demo.lifeserverweb.StringUtil.java

public static boolean checkOnlyInList(String str, List<String> includeStr) {
    boolean isOnly = false;
    char[] chars = str.toCharArray();
    if (CollectionUtils.isEmpty(includeStr)) {
        return isOnly;
    }/*from  w w w .  ja  va 2  s .  co m*/
    String regex = "";
    if (includeStr.contains(INCLUDE_ENGLISH)) {
        regex += "a-zA-Z";
    }
    if (includeStr.contains(INCLUDE_NUMBER)) {
        regex += "0-9";
    }
    if (includeStr.contains(INCLUDE_ZH_GBK)) {
        regex += "\u4081-\ufefe";
    }
    regex = "^[" + regex + "]+?$";
    Pattern pattern = Pattern.compile(regex);
    Matcher match = pattern.matcher(str);
    isOnly = match.matches();
    return isOnly;
}

From source file:com.iana.dver.dao.impl.DverDetailsDaoImpl.java

@Override
public List<DverDetail> findSelectedRejectedDversForExcel(final List<Integer> dverSelectedIdList)
        throws DataAccessException {

    logger.info("Find selected Rejected Dvers for Excel report....");
    List rejectedDvers = getHibernateTemplate().executeFind(new HibernateCallback<List<DverDetail>>() {
        @Override/*from   w w  w .  j a  v  a 2s  .  c o m*/
        public List<DverDetail> doInHibernate(Session session) throws HibernateException, SQLException {
            Query q = session.createQuery(FIND_SELECTED_REJECTED_DVERS);
            q.setParameterList("dverDetailIds", dverSelectedIdList);
            return q.list();
        }
    });

    return (!CollectionUtils.isEmpty(rejectedDvers)) ? rejectedDvers : new ArrayList<DverDetail>();
}

From source file:pe.gob.mef.gescon.web.ui.ParametroMB.java

public void setSelectedRow(ActionEvent event) {
    try {//from  www  . j  a v  a 2s  . c o  m
        if (event != null) {
            int index = Integer.parseInt((String) JSFUtils.getRequestParameter("index"));
            if (!CollectionUtils.isEmpty(this.getFilteredListaParametro())) {
                this.setSelectedParametro(this.getFilteredListaParametro().get(index));
            } else {
                this.setSelectedParametro(this.getListaParametro().get(index));
            }
            this.setFilteredListaParametro(new ArrayList());
        }
    } catch (Exception e) {
        log.error(e.getMessage());
        e.printStackTrace();
    }
}

From source file:cn.loveapple.service.controller.health.action.BasalBodyTemperatureController.java

/**
 * ???????/* w  w  w .j  a  va 2 s. c o m*/
 * 
 * @param form
 * @param result
 * @return
 */
@RequestMapping(value = "regist.json")
public MappingJacksonJsonView registBbt(@Valid BasalBodyTemperatureForm form, BindingResult result,
        HttpSession session, Locale locale) {

    if (!hasAttributeInSession(session, LOVEAPPLE_MEMBER)) {
        return userErrorJsonView(result);
    }
    BasalBodyTemperatureValidator validator = new BasalBodyTemperatureValidator(messageSource, locale);
    validator.validate(form, result);
    if (result.hasErrors()) {
        return userErrorJsonView(result);
    }

    LoveappleMemberModel member = (LoveappleMemberModel) session.getAttribute(LOVEAPPLE_MEMBER);

    //????????
    List<BasalBodyTemperatureModel> bbtList = null;
    try {
        if (StringUtils.isEmpty(form.getMeasureDay())) {
            form.setMeasureDay(DateUtil.toDateString(new Date(), DateUtil.DATE_PTTERN_YYYYMMDD));
        }

        bbtList = basalBodyTemperatureService.findBasalBodyTemperatureByUser(member.getMail(),
                form.getMeasureDay(), form.getMeasureDay());
    } catch (IllegalArgumentException e) {
        throw e;
    }

    //?/??
    BasalBodyTemperatureModel bbt = createBasalBodyTemperatureModel(form, member);

    if (CollectionUtils.isEmpty(bbtList)) {
        bbt = basalBodyTemperatureService.insertBasalBodyTemperatureModel(bbt);
    } else {
        bbt = basalBodyTemperatureService.updateBasalBodyTemperatureModel(bbt);
    }

    //TODO ?JSON
    JsonResponse response = new JsonResponse();
    response.setStatus(STATUS_OK);
    response.setStatusCode(STATUS_CODE_SUCCESS);
    response.setData(bbt);

    return response;
}

From source file:fr.mby.utils.spring.beans.factory.BasicProxywiredManager.java

@Override
public void modifyAllProxywiredDepencies(final Class<?> proxywiredType, final LinkedHashSet<String> beanNames) {
    Assert.notNull(proxywiredType, "No Proxywired type provided !");

    final Collection<IManageableProxywired> sameTypeDependencies = this.byTypeStorage.get(proxywiredType);

    if (!CollectionUtils.isEmpty(sameTypeDependencies)) {
        final LinkedHashMap<String, Object> dependencies = this.buildDependencyToWireMap(beanNames);

        // Modify all dependencies of this type
        for (final IManageableProxywired dependencyToModify : sameTypeDependencies) {
            this.modifyDependency(dependencies, dependencyToModify);
            BasicProxywiredManager.LOG.info(
                    "All Proxywired dependency of type: [{}] were modified with beans: [{}]",
                    proxywiredType.getName(), beanNames);
        }/*from  w ww. j  a va 2  s  .c  om*/

    } else {
        throw new IllegalStateException("Unable to found a Prowywired resource for this Type !");
    }
}