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.github.cric.app.ui.SettingPanel.java

private void populateMatchList() {

    if (StringUtils.isBlank(System.getProperty(API_KEY_PROP))) {

        setMessage("enter api key provided by cricapi.com");
        return;/*from  w w  w .  j  a  v a2s  .  co  m*/
    }

    try {
        matchList = scoreService.getCurrentMatches();

        if (CollectionUtils.isEmpty(matchList)) {
            setMessage("no ongoing matches");
        } else {
            populateCombo();
            setAllEnabled(true);
            setMessage("select match to get popup notifcation");
        }
        apiKeyField.setEnabled(false);
    } catch (Exception e) {
        LOG.warn(e.getMessage(), e);
        setMessage(e.getMessage());
    }
}

From source file:org.springmodules.cache.config.AbstractCacheSetupStrategyParser.java

/**
 * Parses the given XML element which sub-elements containing the properties
 * of the caching models to create./*from  ww  w  .  j a v a 2s . c  om*/
 * 
 * @param element
 *          the XML element to parse
 * @return a map containing the parsed caching models.The key of each element
 *         is the value of the XML attribute <code>target</code> (a String)
 *         and the value is the caching model (an instance of
 *         <code>CachingModel</code>)
 */
private Map parseCachingModels(Element element) {
    List modelElements = DomUtils.getChildElementsByTagName(element, "caching");
    if (CollectionUtils.isEmpty(modelElements)) {
        return null;
    }

    String cacheModelKey = getCacheModelKey();
    Map models = new HashMap();
    int modelElementCount = modelElements.size();

    for (int i = 0; i < modelElementCount; i++) {
        Element modelElement = (Element) modelElements.get(i);
        String key = modelElement.getAttribute(cacheModelKey);

        CachingModel model = cacheModelParser.parseCachingModel(modelElement);
        models.put(key, model);
    }

    return models;
}

From source file:com.deloitte.smt.service.SignalDetectionService.java

/**
 * @param signalDetection//  w  ww.j  a v  a2  s .  co m
 * @param soc
 */
private void saveHlgt(SignalDetection signalDetection, Soc soc) {
    List<Hlgt> hlgts = soc.getHlgts();
    if (!CollectionUtils.isEmpty(hlgts)) {
        for (Hlgt hlgt : hlgts) {
            hlgt.setSocId(soc.getId());
            hlgt.setDetectionId(signalDetection.getId());
        }
        hlgtRepository.save(hlgts);
    }
}

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

@Override
public int countAllUsersByType(Integer userTypeId) throws DataAccessException {
    logger.info("Count AllUsers By Type ");
    List result = null;/*from ww w.j  av a  2s  .  c o  m*/
    result = getHibernateTemplate().find(
            "SELECT COUNT(DU.dverUserId) FROM DverUsers DU WHERE DU.dverUserType.dverUserTypeId in (2,3)");
    return CollectionUtils.isEmpty(result) ? 0 : Integer.valueOf(result.get(0).toString());
}

From source file:com.ecs.cms.web.mvc.view.MappingJacksonJsonView.java

/**
 * Filters out undesired attributes from the given model. The return value
 * can be either another {@link Map} or a single value object.
 * <p>//from  w w  w . j av  a  2  s.  c  o  m
 * The default implementation removes {@link BindingResult} instances and
 * entries not included in the {@link #setRenderedAttributes
 * renderedAttributes} property.
 * 
 * @param model
 *            the model, as passed on to {@link #renderMergedOutputModel}
 * @return the object to be rendered
 */
protected Object filterModel(Map<String, Object> model) {
    Map<String, Object> result = new HashMap<String, Object>(model.size());
    Set<String> renderedAttributes = (!CollectionUtils.isEmpty(this.modelKeys) ? this.modelKeys
            : model.keySet());
    for (Map.Entry<String, Object> entry : model.entrySet()) {
        if (!(entry.getValue() instanceof BindingResult) && renderedAttributes.contains(entry.getKey())) {
            result.put(entry.getKey(), entry.getValue());
        }
    }
    return (this.extractValueFromSingleKeyModel && result.size() == 1 ? result.values().iterator().next()
            : result);
}

From source file:com.stormpath.spring.security.authz.CustomDataPermissionsEditor.java

@Override
public Set<String> getPermissionStrings() {

    Collection<String> perms = lookupPermissionStrings();

    if (CollectionUtils.isEmpty(perms)) {
        return Collections.emptySet();
    }//  w  w w .  j  a  v a  2s .  com

    Set<String> set;

    if (perms instanceof List) {
        set = asSet(getFieldName(), (List) perms);
    } else {
        assert perms instanceof Set : "perms instance must be a Set<String>";
        set = (Set<String>) perms;
    }

    return Collections.unmodifiableSet(set);
}

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

@Override
public int filterRejectedDversCount(Map<String, String> filtermap) throws DataAccessException {
    Session session = SessionFactoryUtils.getSession(this.getSessionFactory(), true);
    String filterQuery = generateQuery(filtermap, Boolean.TRUE);
    logger.info("filter query for Count Rejected DVER's is :: " + filterQuery);
    Query filters = session.createQuery(filterQuery);
    List result = filters.list();
    session.close();//from ww w.j a  va 2 s .co  m
    return CollectionUtils.isEmpty(result) ? 0 : Integer.valueOf(result.get(0).toString());
}

From source file:org.agatom.springatom.cmp.wizards.data.result.WizardResult.java

public WizardResult setDebugData(final ModelMap debugData) {
    if (CollectionUtils.isEmpty(debugData)) {
        return this;
    }/*from   w  w w.j  a v a 2  s . c  o m*/
    if (this.debugData == null) {
        this.debugData = debugData;
    } else {
        this.debugData.putAll(debugData);
    }
    return this;
}

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

public void save(ActionEvent event) {
    try {/*from  ww w  .j  a v  a2 s .  c  o  m*/
        if (CollectionUtils.isEmpty(this.getListaAlerta())) {
            this.setListaAlerta(Collections.EMPTY_LIST);
        }
        Alerta alerta = new Alerta();
        alerta.setVnombre(this.getNombre());
        alerta.setVdescripcion(this.getDescripcion());
        alerta.setNparametroid(this.getSelectedParametro());
        alerta.setDfechini(this.getFechfin());
        alerta.setDfechfin(this.getFechfin());
        alerta.setNcondicion1(this.getCondicion1());
        alerta.setNcondicion2(this.getCondicion2());
        alerta.setNtipo1(this.getTipo1());
        alerta.setNtipo2(this.getTipo2());
        alerta.setNuseraplica(this.getUseraplica());
        alerta.setNvalor1(this.getValor1());
        alerta.setNvalor2(this.getValor2());
        if (!errorValidation(alerta)) {
            LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB");
            User user = loginMB.getUser();
            AlertaService service = (AlertaService) ServiceFinder.findBean("AlertaService");
            alerta.setNalertaid(service.getNextPK());
            alerta.setVnombre(StringUtils.upperCase(this.getNombre().trim()));
            alerta.setVdescripcion(StringUtils.capitalize(this.getDescripcion().trim()));
            alerta.setNactivo(BigDecimal.ONE);
            alerta.setDfechacreacion(new Date());
            alerta.setVusuariocreacion(user.getVlogin());
            service.saveOrUpdate(alerta);
            this.setListaAlerta(service.getAlertas());
            this.cleanAttributes();
            RequestContext.getCurrentInstance().execute("PF('newDialog').hide();");
        }
    } catch (Exception e) {
        log.error(e.getMessage());
        e.printStackTrace();
    }
}

From source file:org.esco.cas.client.CasSingleLogoutClusterFilter.java

@Override
public void init(final FilterConfig config) throws ServletException {
    // Get local hostName on initialization
    this.clientHostName = config.getInitParameter(CasSingleLogoutClusterFilter.CLIENT_HOSTNAME_PARAMETER);

    if (!StringUtils.hasText(this.clientHostName)) {
        try {/*from  w  w w .  j a  v a 2 s. c  o  m*/

            final InetAddress localMachine = InetAddress.getLocalHost();
            this.clientHostName = localMachine.getHostName();
            CasSingleLogoutClusterFilter.LOG.info("Detected Hostname for local machine: [{}]",
                    this.clientHostName);
        } catch (UnknownHostException e) {
            final String errorMsg = String.format(
                    "Error while detecting IP Address of server. You need to configure the filter parameter: [%1$s]",
                    CasSingleLogoutClusterFilter.CLIENT_HOSTNAME_PARAMETER);
            CasSingleLogoutClusterFilter.LOG.error(errorMsg, e);
        }
    }

    // Get comma delimited list of peer dns names from a filter config
    final String peerList = config.getInitParameter(CasSingleLogoutClusterFilter.PEERS_PARAMETER);
    if (!StringUtils.hasText(peerList)) {
        CasSingleLogoutClusterFilter.LOG
                .warn("No peers URL configured the CasSingleLogoutClusterFilter will not works !");
    }

    String[] peersDescription = peerList.split(",");
    for (String peerDescription : peersDescription) {
        try {
            this.peers.add(new Peer(peerDescription));
        } catch (MalformedURLException e) {
            // We don't block the webapp initializiation. Just log an error.
            CasSingleLogoutClusterFilter.LOG.error(
                    "Malformed peer URL [{}] among CasSingleLogoutClusterFilter peers !", peerDescription);
            //throw new ServletException("Malformed URL among CasSingleLogoutClusterFilter peers !", e);
        }
    }

    if (!StringUtils.hasText(this.clientHostName)) {
        CasSingleLogoutClusterFilter.LOG
                .warn("No client hostname configured the CasSingleLogoutClusterFilter may not works !");
    }

    if (CollectionUtils.isEmpty(this.peers)) {
        CasSingleLogoutClusterFilter.LOG
                .warn("No valid peers URL configured the CasSingleLogoutClusterFilter will not works !");
    }

    CasSingleLogoutClusterFilter.LOG.info("Client hostname: [{}]", this.clientHostName);
    CasSingleLogoutClusterFilter.LOG.info("SLO cluster peers: [{}]", peerList.toString());
}