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.slyak.services.file.service.DefaultFileService.java

@Override
public FileInfo getOwnerFile(String owner) {
    List<FileInfo> infos = getOwnerFiles(owner);
    if (CollectionUtils.isEmpty(infos)) {
        return null;
    }/*w  ww.j  a  va  2 s.c  o  m*/
    return infos.get(0);
}

From source file:com.sinet.gage.delta.DomainUpdatesImporter.java

/**
 * Performs the delta imports for District & School Domain
 * /*from  ww w.jav a 2  s  .com*/
 * @param domainIdsToProcessInsert
 */
public void processInsertsForDomains(Set<Integer> domainIdsToProcessInsert) {
    Set<Integer> domainIdsForInsert;
    List<DomainResponse> domainResponseList;
    List<Domain> domainList = new ArrayList<>();

    for (Integer domainId : domainIdsToProcessInsert) {

        domainIdsForInsert = signalManager.getDomainIdsForDeltaImportsForADomain(domainId,
                serverSettings.getEntityCreatedSignalTypeCode());

        if (!CollectionUtils.isEmpty(domainIdsForInsert)) {
            log.debug("Domain Ids to be inserted: " + domainIdsForInsert);
            String idsString = domainIdsForInsert.stream().map(Object::toString)
                    .collect(Collectors.joining(", "));
            domainResponseList = getDomainsWithData(domainId, idsString);

            for (DomainResponse domainResponse : domainResponseList) {
                DomainResponse parentDomainResponse = dlapDomainClient.getDomain(null,
                        Long.parseLong(domainId.toString()));
                Domain domain = mapToDomain(domainResponse);
                if (domainResponse.getData() != null && domainResponse.getData().getCustomization() != null
                        && domainResponse.getData().getCustomization().getEdivatelearn() != null) {
                    if ("DISTRICT".equalsIgnoreCase(
                            domainResponse.getData().getCustomization().getEdivatelearn().getDomaintype())) {
                        domain.setStateDomainId(Long.parseLong(parentDomainResponse.getId()));
                        domain.setStateDomainName(parentDomainResponse.getName());
                        domain.setParentDomainName(parentDomainResponse.getName());
                    } else if ("SCHOOL".equalsIgnoreCase(
                            domainResponse.getData().getCustomization().getEdivatelearn().getDomaintype())) {
                        DomainResponse stateDomainResponse = dlapDomainClient.getDomain(null,
                                Long.parseLong(parentDomainResponse.getParentid()));
                        domain.setStateDomainId(Long.parseLong(stateDomainResponse.getId()));
                        domain.setStateDomainName(stateDomainResponse.getName());
                        domain.setParentDomainName(parentDomainResponse.getName());
                    }
                } else {
                    domain.setStateDomainId(Long.parseLong(parentDomainResponse.getId()));
                    domain.setStateDomainName(parentDomainResponse.getName());
                    domain.setParentDomainName(parentDomainResponse.getName());
                }
                domainList.add(domain);
            }
            log.debug("Inserting domain ids: " + domainId);
            if (!CollectionUtils.isEmpty(domainList)) {
                domainsRepository.insertDomains(domainList);
            }
        }
    }
}

From source file:com.payu.ratel.proxy.BroadcastingInvocationHandler.java

@Override
public synchronized Object invoke(Object o, Method method, Object[] args) throws Throwable {
    Collection<String> serviceAddresses = fetchStrategy.fetchServiceAddresses(EVENT_RECEIVER_CLASS.getName());

    if (CollectionUtils.isEmpty(serviceAddresses)) {
        LOGGER.error("No instance named{}", EVENT_RECEIVER_CLASS.getName());
        return null;
    }/*from   w  w  w  .ja v a 2s  .  c o  m*/

    for (String serviceAddress : serviceAddresses) {
        final Object clientProxy = clientProxyGenerator.generate(EVENT_RECEIVER_CLASS, serviceAddress, timeout);
        RECEIVE_METHOD_HANDLER.invoke(clientProxy, args);
    }

    return null;
}

From source file:com.alibaba.china.talos.service.impl.InitAvStageInfo.java

@Override
public void execute() {
    AtomAuthInstanceParam atomAuthInstanceParam = new AtomAuthInstanceParam();
    atomAuthInstanceParam.setPackageCode("AV");
    atomAuthInstanceParam.setStatus(AuthStatusEnum.process.name());
    List<AtomAuthInstanceDO> atomAuthInstanceList = atomAuthInstanceDAO
            .findAtomAuthInstanceDOByParam(atomAuthInstanceParam);
    if (!CollectionUtils.isEmpty(atomAuthInstanceList)) {
        List<Long> atomAuthIds = new ArrayList<Long>();
        for (AtomAuthInstanceDO atomAuth : atomAuthInstanceList) {
            atomAuthIds.add(atomAuth.getId());
        }/*from   w  w w.  java  2s.  co m*/
        AvProcessStatusParam param = new AvProcessStatusParam();
        param.setAtomAuthIds(atomAuthIds);
        param.setAvStatus("auth");
        List<AvProcessStatus> avProcessStatusList = avProcessStatusService.findBy(param);
        if (!CollectionUtils.isEmpty(avProcessStatusList)) {
            for (AvProcessStatus avProcessStatus : avProcessStatusList) {
                try {
                    StageInfoDO stageInfoDO = new StageInfoDO();
                    stageInfoDO.setAtomAuthId(avProcessStatus.getAtomAuthId());
                    stageInfoDO.setAuthFlowName("AV");
                    stageInfoDO.setGmtCreate(new Date());
                    stageInfoDO.setGmtModified(new Date());
                    stageInfoDO.setStageName("processing");
                    stageInfoDO.setStageStatus(StageStatus.RUNNING.getValue());
                    stageInfoDAO.insert(stageInfoDO);
                    logger.info("initAvStageInfo success,the atomAuthId=" + avProcessStatus.getAtomAuthId()
                            + ",stage=process");
                } catch (Exception e) {
                    logger.error("initAvStageInfo error,the atomAuthId=" + avProcessStatus.getAtomAuthId()
                            + ",stage=process,exception message=" + e.getMessage());
                }
            }
        }

        param.setAtomAuthIds(atomAuthIds);
        param.setAvStatus("pass");
        avProcessStatusList = avProcessStatusService.findBy(param);

        if (!CollectionUtils.isEmpty(avProcessStatusList)) {
            for (AvProcessStatus avProcessStatus : avProcessStatusList) {
                try {
                    StageInfoDO stageInfoDO = new StageInfoDO();
                    stageInfoDO.setAtomAuthId(avProcessStatus.getAtomAuthId());
                    stageInfoDO.setAuthFlowName("AV");
                    stageInfoDO.setGmtCreate(new Date());
                    stageInfoDO.setGmtModified(new Date());
                    stageInfoDO.setStageName("waitForSend");
                    stageInfoDO.setStageStatus(StageStatus.RUNNING.getValue());
                    stageInfoDAO.insert(stageInfoDO);
                    logger.info("initAvStageInfo success,the atomAuthId=" + avProcessStatus.getAtomAuthId()
                            + ",stage=waitForSend");
                } catch (Exception e) {
                    logger.error("initAvStageInfo error,the atomAuthId=" + avProcessStatus.getAtomAuthId()
                            + ",stage=waitForSend,exception message=" + e.getMessage());
                }
            }
        }

    }
}

From source file:com.expedia.seiso.domain.service.impl.SearchEngineImpl.java

@Override
@SneakyThrows({ ExecutionException.class, InterruptedException.class })
public SearchResults search(@NonNull SearchQuery query, @NonNull Pageable pageable) {
    val allResults = new SearchResults();
    val tokens = query.getTokens();
    log.debug(query.getQuery());/*from   w w w. j  a va2s.c  o  m*/
    if (!CollectionUtils.isEmpty(tokens)) {
        val tasks = createSearchTasks(tokens, pageable);
        val futures = executorService.invokeAll(tasks);
        for (val future : futures) {
            val serp = future.get();
            allResults.putTypedSerp(serp.getItemClass(), serp.getResultPage());
        }
    }
    return allResults;
}

From source file:nc.noumea.mairie.organigramme.services.impl.ReturnMessageServiceImpl.java

public boolean gererReturnMessage(ReturnMessageDto returnMessageDto, boolean afficherSiInfo) {
    if (returnMessageDto == null) {
        return true;
    }/*  www.j  a v  a2 s  .  co  m*/

    if (returnMessageDto.getErrors().size() > 0 || returnMessageDto.getInfos().size() > 0) {
        List<String> listeInformation = new ArrayList<String>();
        List<String> listeErreur = new ArrayList<String>();

        for (String error : returnMessageDto.getErrors()) {
            listeErreur.add(error);
        }
        for (String info : returnMessageDto.getInfos()) {
            listeInformation.add(info);
        }

        if (!CollectionUtils.isEmpty(listeErreur)) {
            showNotificationErreur(StringUtils.join(listeErreur, "<br><br>"));
            return false;
        }

        if (afficherSiInfo && !CollectionUtils.isEmpty(listeInformation)) {
            showNotificationStandard(StringUtils.join(listeInformation, "<br><br>"));
        }
    }

    return true;
}

From source file:com.nortal.petit.orm.statement.UpdateStatement.java

@Override
public void exec() {
    super.exec();
    if (!CollectionUtils.isEmpty(getBeans()) && getStatementBuilder().getInterceptor() != null) {
        invokeInterceptor();//from   ww w. j a v a2 s  .co  m
    }
}

From source file:cn.wanghaomiao.seimi.core.SeimiContext.java

public SeimiContext() {
    register(ScanConfig.class);
    init();/*  ww w . j a v  a2 s . c o m*/
    if (!CollectionUtils.isEmpty(crawlers)) {
        prepareCrawlerModels();
        workersPool = Executors.newFixedThreadPool(
                BASE_THREAD_NUM * Runtime.getRuntime().availableProcessors() * crawlers.size());
        prepareWorkerThread();
    } else {
        logger.error("can not find any crawlers,please check!");
    }
}

From source file:com.consol.citrus.samples.kubernetes.ListKubernetesResourcesIT.java

@Test
@CitrusTest//from   w  ww.j  a  v  a2s .  co m
public void testListPods() {
    kubernetes().client(k8sClient).pods().list().namespace("default").validate((result, context) -> {
        Assert.assertFalse(CollectionUtils.isEmpty(result.getResult().getItems()));
    });
}