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.kuali.coeus.s2sgen.impl.generate.support.NSFKeyPersonExpandedV1_0Generator.java

protected void saveKeyPersonAttachmentsToProposal() {
    if (!CollectionUtils.isEmpty(extraPersons)) {
        saveKeyPersonAttachments();
        saveKeypersonProfileObject();
    }
}

From source file:com.alibaba.otter.node.etl.select.selector.MessageParser.java

/**
 * canal??Entry?otter/*from   w  ww  . jav  a2 s . co m*/
 * 
 * <pre>
 * ???
 * 1. Transaction Begin/End
 * 2. retl.retl_client/retl.retl_mark ????
 * 3. retl.xdual canal?
 * </pre>
 */
public List<EventData> parse(Long pipelineId, List<Entry> datas) throws SelectException {
    List<EventData> eventDatas = new ArrayList<EventData>();
    Pipeline pipeline = configClientService.findPipeline(pipelineId);
    List<Entry> transactionDataBuffer = new ArrayList<Entry>();
    // hzus->hz???us??
    PipelineParameter pipelineParameter = pipeline.getParameters();
    boolean enableLoopbackRemedy = pipelineParameter.isEnableRemedy() && pipelineParameter.isHome()
            && pipelineParameter.getRemedyAlgorithm().isLoopback();
    boolean isLoopback = false;
    boolean needLoopback = false; // ??loopback???otter???????

    long now = new Date().getTime();
    try {
        for (Entry entry : datas) {
            switch (entry.getEntryType()) {
            case TRANSACTIONBEGIN:
                isLoopback = false;
                break;
            case ROWDATA:
                String tableName = entry.getHeader().getTableName();
                // ?retl_mark
                boolean isMarkTable = tableName.equalsIgnoreCase(pipeline.getParameters().getSystemMarkTable());
                if (isMarkTable) {
                    RowChange rowChange = RowChange.parseFrom(entry.getStoreValue());
                    if (!rowChange.getIsDdl()) {
                        int loopback = checkLoopback(pipeline, rowChange.getRowDatas(0));
                        if (loopback == 2) {
                            needLoopback |= true; // ????
                        }

                        isLoopback |= loopback > 0;
                    }
                }

                // otter3.0schmea????
                boolean isCompatibleLoopback = tableName.equalsIgnoreCase(compatibleMarkTable);

                if (isCompatibleLoopback) {
                    RowChange rowChange = RowChange.parseFrom(entry.getStoreValue());
                    if (!rowChange.getIsDdl()) {
                        int loopback = checkCompatibleLoopback(pipeline, rowChange.getRowDatas(0));
                        if (loopback == 2) {
                            needLoopback |= true; // ????
                        }
                        isLoopback |= loopback > 0;
                    }
                }

                if ((!isLoopback || (enableLoopbackRemedy && needLoopback)) && !isMarkTable
                        && !isCompatibleLoopback) {
                    transactionDataBuffer.add(entry);
                }
                break;
            case TRANSACTIONEND:
                if (!isLoopback || (enableLoopbackRemedy && needLoopback)) {
                    // ??
                    for (Entry bufferEntry : transactionDataBuffer) {
                        List<EventData> parseDatas = internParse(pipeline, bufferEntry);
                        if (CollectionUtils.isEmpty(parseDatas)) {// ?ddlnull
                            continue;
                        }

                        // ??
                        long totalSize = bufferEntry.getHeader().getEventLength();
                        long eachSize = totalSize / parseDatas.size();
                        for (EventData eventData : parseDatas) {
                            if (eventData == null) {
                                continue;
                            }

                            eventData.setSize(eachSize);// ?
                            if (needLoopback) {// ??
                                // ???db
                                if (now - eventData.getExecuteTime() > 1000
                                        * pipeline.getParameters().getRemedyDelayThresoldForMedia()) {
                                    eventData.setSyncConsistency(SyncConsistency.MEDIA);
                                } else {
                                    eventData.setSyncConsistency(SyncConsistency.BASE);
                                }
                                eventData.setRemedy(true);
                            }
                            eventDatas.add(eventData);
                        }
                    }
                }

                isLoopback = false;
                needLoopback = false;
                transactionDataBuffer.clear();
                break;
            default:
                break;
            }
        }

        // ???TRANSACTIONEND
        if (!isLoopback || (enableLoopbackRemedy && needLoopback)) {
            // ??
            for (Entry bufferEntry : transactionDataBuffer) {
                List<EventData> parseDatas = internParse(pipeline, bufferEntry);
                if (CollectionUtils.isEmpty(parseDatas)) {// ?ddlnull
                    continue;
                }

                // ??
                long totalSize = bufferEntry.getHeader().getEventLength();
                long eachSize = totalSize / parseDatas.size();
                for (EventData eventData : parseDatas) {
                    if (eventData == null) {
                        continue;
                    }

                    eventData.setSize(eachSize);// ?
                    if (needLoopback) {// ??
                        // ???db
                        if (now - eventData.getExecuteTime() > 1000
                                * pipeline.getParameters().getRemedyDelayThresoldForMedia()) {
                            eventData.setSyncConsistency(SyncConsistency.MEDIA);
                        } else {
                            eventData.setSyncConsistency(SyncConsistency.BASE);
                        }
                    }
                    eventDatas.add(eventData);
                }
            }
        }
    } catch (Exception e) {
        throw new SelectException(e);
    }

    return eventDatas;
}

From source file:net.sf.sze.service.impl.converter.ZeugnisCreatorServiceImpl.java

/**
 * {@inheritDoc}/*from  w  w  w  .  j  ava 2s. com*/
 */
@Override
public File createZeugnisse(Schulhalbjahr halbjahr, Klasse klasse) {
    final List<Zeugnis> zeugnisse = zeugnisDao.findAllByFormularSchulhalbjahrAndFormularKlasse(halbjahr,
            klasse);
    if (CollectionUtils.isEmpty(zeugnisse)) {
        return null;
    }
    for (final Zeugnis zeugnis : zeugnisse) {
        createZeugnis(zeugnis);
    }

    return createCompletePdfs(halbjahr, klasse);
}

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

/**
 * @param signalDetection//  w  w w .ja  v a 2s. co m
 */
private void saveSmq(SignalDetection signalDetection) {
    List<Smq> smqs = signalDetection.getSmqs();
    if (!CollectionUtils.isEmpty(smqs)) {
        for (Smq smq : smqs) {
            smq.setDetectionId(signalDetection.getId());
        }
        smqs = smqRepository.save(smqs);
        for (Smq smq : smqs) {
            saveSmqPt(signalDetection, smq);
        }
    }
}

From source file:com.excilys.ebi.bank.util.Asserts.java

public static void notEmpty(Collection<?> collection, String messagePattern, Object... args) {
    if (CollectionUtils.isEmpty(collection)) {
        throw new IllegalArgumentException(MessageFormatter.arrayFormat(messagePattern, args).getMessage());
    }//  w w w. j av a  2 s.  c  o m
}

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

/**
 * Retrieve all assertions, normal ones and encrypted ones if a private key was provided.
 * /*from   w  w  w .j  a v  a2 s.  c  om*/
 * @param samlResponse
 *            the saml response containing the assertions.
 * @return the list of all assertions.
 * @throws DecryptionException
 *             in case of decryption problem.
 * @throws UnsupportedSamlOperation
 */
protected List<Assertion> retrieveAllAssertions(final Response samlResponse)
        throws DecryptionException, UnsupportedSamlOperation {
    final List<Assertion> allAssertions = new ArrayList<Assertion>();

    if (samlResponse != null) {
        // Normal Assertions
        final List<Assertion> normalAssertions = samlResponse.getAssertions();
        if (!CollectionUtils.isEmpty(normalAssertions)) {
            allAssertions.addAll(normalAssertions);
        }

        // Encrypted Assertions
        final List<EncryptedAssertion> encAssertions = samlResponse.getEncryptedAssertions();
        if (!CollectionUtils.isEmpty(encAssertions)) {
            for (final EncryptedAssertion encAssertion : samlResponse.getEncryptedAssertions()) {
                final Assertion assertion = this.decryptAssertion(encAssertion);

                allAssertions.add(assertion);
            }
        }
    }

    return allAssertions;
}

From source file:com.qpark.eip.core.failure.FailureAssert.java

/**
 * Assert that a collection has elements; that is, it must not be
 * <code>null</code> and must have at least one element.
 *
 * <pre class="code">/* w w w. j a  v a  2  s  .c om*/
 * Assert.notEmpty(collection, &quot;Collection must have elements&quot;);
 * </pre>
 *
 * @param collection
 *            the collection to check
 * @param errorCode
 *            the error code to use if the assertion fails
 * @throws IllegalArgumentException
 *             if the collection is <code>null</code> or has no elements
 */
public static void notEmpty(final Collection<?> collection, final String errorCode) {
    if (CollectionUtils.isEmpty(collection)) {
        BaseFailureHandler.throwFailureException(errorCode);
    }
}

From source file:com.jim.im.topic.service.TopicServiceImpl.java

private TopicInfo getSingleTopicInfo(Integer ownerId, String appId, String tenantId,
        TopicOwnerType topicOwnerType, TopicType topicType) throws ImParamException {

    List<String> topicNames = generateTopicName(ownerId, appId, tenantId, topicOwnerType, topicType);
    List<TopicInfo> topicInfoList = getTopicInfo(topicNames);
    if (CollectionUtils.isEmpty(topicInfoList) || topicInfoList.size() != 1)
        throw new ImParamException(
                "Duplicate topic info error, because there expect get one topic info, but here has two.");
    return topicInfoList.get(0);
}

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

/**
 * Parses the given XML element containing references to the caching listeners
 * to be added to the caching setup strategy.
 * //  w  ww. ja  va2s.  co m
 * @param element
 *          the XML element to parse
 * @param parserContext
 *          the parser context
 * @return a list containing references to caching listeners already
 *         registered in the given register
 * @throws IllegalStateException
 *           if any of the given ids reference a caching listener that does
 *           not exist in the registry
 * @throws IllegalStateException
 *           if the given id references a caching listener that is not an
 *           instance of <code>CachingListener</code>
 * @throws IllegalStateException
 *           if the caching listener elements does not contain a reference to
 *           an existing caching listener and does not contain an inner
 *           definition of a caching listener
 */
private List parseCachingListeners(Element element, ParserContext parserContext) throws IllegalStateException {

    List listenersElements = DomUtils.getChildElementsByTagName(element, "cachingListeners");

    if (CollectionUtils.isEmpty(listenersElements)) {
        return null;
    }

    Element listenersElement = (Element) listenersElements.get(0);
    List listenerElements = DomUtils.getChildElementsByTagName(listenersElement, "cachingListener");

    ManagedList listeners = new ManagedList();
    boolean registerCachingListener = true;
    int listenerCount = listenerElements.size();

    for (int i = 0; i < listenerCount; i++) {
        Element listenerElement = (Element) listenerElements.get(i);

        Object cachingListener = beanReferenceParser.parse(listenerElement, parserContext,
                registerCachingListener);
        cachingListenerValidator.validate(cachingListener, i, parserContext);
        listeners.add(cachingListener);
    }

    return listeners;
}