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:org.sakuli.exceptions.SakuliExceptionHandler.java

static boolean containsException(TestSuite testSuite) {
    if (testSuite.getException() != null) {
        return true;
    }//from   ww w .  j  ava 2  s.c om
    if (!CollectionUtils.isEmpty(testSuite.getTestCases())) {
        for (TestCase tc : testSuite.getTestCases().values()) {
            if (tc.getException() != null) {
                return true;
            }
            for (TestCaseStep step : tc.getSteps()) {
                if (step.getException() != null) {
                    return true;
                }
            }
        }
    }
    return false;
}

From source file:com.goldCityWeb.webservice.WS_Company.java

@RequestMapping(value = "listhotc", method = { RequestMethod.GET, RequestMethod.POST })
public @ResponseBody JsonResWrapper listhotcomp(Model view, HttpServletRequest request,
        @RequestParam(required = false) Integer type, @RequestParam(required = false) String name) {
    JsonResWrapper jrw = new JsonResWrapper();
    PageSupport ps = PageSupport.initPageSupport(request);
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("verify_status", 1);

    if (!StringUtils.isBlank(name)) {
        param.put("name", name);
        //view.addAttribute("name", name);
    }/*from  www .j  a  va 2s  . c  o  m*/
    if (type != null && type.intValue() > 0) {
        param.put("type", type);
        //view.addAttribute("type", type);
    }

    List<Company> comList = companyService.queryHotCompanyList(ps, param);
    if (!CollectionUtils.isEmpty(comList)) {
        for (Company c : comList) {
            if (!StringUtils.isBlank(c.getLogo())) {
                c.setLogo(SettingUtils.getCommonSetting("base.image.url") + c.getLogo());
            }
        }
    } else {
        comList = new ArrayList<Company>();
    }

    Map<String, Object> data = new HashMap<String, Object>();
    data.put("hotcompany", comList);
    jrw.setData(data);
    return jrw;
}

From source file:com.alibaba.dubbo.config.spring.context.annotation.DubboConfigBindingRegistrar.java

private void registerDubboConfigBeans(String prefix, Class<? extends AbstractConfig> configClass,
        boolean multiple, BeanDefinitionRegistry registry) {

    PropertySources propertySources = environment.getPropertySources();

    Map<String, String> properties = getSubProperties(propertySources, prefix);

    if (CollectionUtils.isEmpty(properties)) {
        if (log.isDebugEnabled()) {
            log.debug("There is no property for binding to dubbo config class [" + configClass.getName()
                    + "] within prefix [" + prefix + "]");
        }// w  w  w. j ava 2 s  . c  o  m
        return;
    }

    Set<String> beanNames = multiple ? resolveMultipleBeanNames(prefix, properties)
            : Collections.singleton(resolveSingleBeanName(configClass, properties, registry));

    for (String beanName : beanNames) {

        registerDubboConfigBean(beanName, configClass, registry);

        MutablePropertyValues propertyValues = resolveBeanPropertyValues(beanName, multiple, properties);

        registerDubboConfigBindingBeanPostProcessor(beanName, propertyValues, registry);

    }

}

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

@Override
public List<Submission> findAllSubmission() {
    HttpHeaders headers = new HttpHeaders();
    headers.add("Accept", MediaType.APPLICATION_JSON_VALUE);
    HttpEntity<String> request = new HttpEntity<String>(headers);
    ResponseEntity<String> response = restTemplate.exchange(getSubmissionUrlTemplate(), HttpMethod.GET, request,
            String.class);

    String responseBody = response.getBody();
    try {//from  w  w  w .  j  a  v a 2s . co m
        if (RestUtil.isError(response.getStatusCode())) {
            ErrorResource error = objectMapper.readValue(responseBody, ErrorResource.class);
            throw new RestClientException("[" + error.getCode() + "] " + error.getMessage());
        } else {
            SubmissionResources resources = objectMapper.readValue(responseBody, SubmissionResources.class);
            //  SubmissionResources resources = restTemplate.getForObject(getSubmissionUrlTemplate(), SubmissionResources.class);
            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();
            // return resources;
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

}

From source file:fr.mby.saml2.sp.opensaml.query.engine.AuthnResponseQueryProcessor.java

@Override
protected void preProcess() throws SamlProcessingException, UnsupportedSamlOperation {
    // Extract Assertions
    final Response authnResponse = this.getOpenSamlObject();
    try {//from  ww w  .  j a v a  2  s  .c om
        this.assertions = this.retrieveAllAssertions(authnResponse);
    } catch (final DecryptionException e) {
        throw new SamlProcessingException("Decryption problem encoutered", e);
    }

    if (CollectionUtils.isEmpty(this.assertions)) {
        throw new SamlProcessingException("No Assertions found in AuthnResponse !");
    }
}

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

private void appendProjectionOnFields(SolrQuery solrQuery, List<Field> fields) {
    if (CollectionUtils.isEmpty(fields)) {
        return;/*from ww  w  . j a va 2s .c o  m*/
    }
    solrQuery.setParam(CommonParams.FL, StringUtils.join(fields, ","));
}

From source file:com.beyond.common.base.AbstractBaseDao.java

public void batchInsert(final List<T> paramObjects) {
    if (CollectionUtils.isEmpty(paramObjects)) {
        throw new QueryException("Batch insert input is empty list.");
    }/*from   w  ww .ja  v  a2s .  c  o  m*/
    try {
        getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
            public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
                executor.startBatch();
                int batchSize = 0;
                for (T t : paramObjects) {
                    executor.insert(getStatementNamespace() + ".insert", t);
                    batchSize++;
                    // every 200 commit
                    if (batchSize == 200) {
                        executor.executeBatch();
                        batchSize = 0;
                    }
                }
                executor.executeBatch();
                return null;
            }
        });

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.creative.dao.repository.GenericDaoImpl.java

private <T> T getUniqueObject(List<T> list, String query) throws IncorrectResultException {
    if (CollectionUtils.isEmpty(list)) {
        throw new IncorrectResultException("Result set is empty for given query :" + query);
    } else if (list.size() > 1) {
        throw new IncorrectResultException("Retrieved more than one value for the given query :" + query);
    } else {/*from  w  w w  .  j  a  va  2 s .  c  o  m*/
        return list.get(0);
    }
}

From source file:com.nortal.petit.orm.StatementSupport.java

/**
 * Inserts beans by primary key mapping/*from www  .j a va 2  s .  com*/
 * 
 * @param beans
 *            Beans to insert
 */
public <B> void insert(Collection<B> beans) {
    if (CollectionUtils.isEmpty(beans)) {
        return;
    }
    insertStm(beans).exec();
}

From source file:cn.loveapple.service.cool.service.health.impl.BasalBodyTemperatureServiceImpl.java

/**
 * /*from   w  ww . j  av a  2  s.com*/
 * {@inheritDoc}
 */
@Override
public BasalBodyTemperatureModel updateBasalBodyTemperatureModel(BasalBodyTemperatureModel bbt) {
    if (bbt == null) {
        throw new IllegalArgumentException("bbt is empty.");
    }

    List<BasalBodyTemperatureModel> tmp = findBasalBodyTemperatureByUser(bbt.getMail(), bbt.getMeasureDay(),
            bbt.getMeasureDay());
    if (CollectionUtils.isEmpty(tmp)) {
        throw new RuntimeException("bbt is invalid. " + ToStringBuilder.reflectionToString(tmp));
    }
    bbt.setKey(tmp.get(0).getKey());

    Date now = new Date();
    bbt.setUpdateDate(now);
    return dmLoveappleModel(bbt);
}