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.banyou.backend.web.front.SearchController.java

@RequestMapping(value = { "toList" }, method = RequestMethod.GET)
public String toList(HttpSession session, @RequestParam(value = "dest", required = false) List<Long> destIds) {
    if (CollectionUtils.isEmpty(destIds)) {
        destIds = Collections.emptyList();
    }// w ww.ja  v  a  2s .co  m
    session.setAttribute(DEST_CODE, destIds.toArray(new Long[0]));
    return "redirect:/front/search/list";
}

From source file:net.sf.sze.frontend.konfiguration.KonfigurationController.java

/**
 * Initialisiert die Zeugnisse.//from  w  w w  .  j  a  v  a2  s . c  om
 * @param formulare die Formulare fr die die Zeugnisse zu initialisieren sind.
 * @param redirectAttributes der Datenspeicher fr den Redirect.
 * @return die anzuzeigende View.
 */
@RequestMapping(value = URL.Configuration.INIT_ZEUGNISSE, method = RequestMethod.POST)
public String initializeZeugnisse(
        @RequestParam(value = URL.Configuration.P_FORMULAR, required = false) List<ZeugnisFormular> formulare,
        RedirectAttributes redirectAttributes) {
    if (CollectionUtils.isEmpty(formulare)) {
        redirectAttributes.addFlashAttribute("message", "Es wurde kein Formular ausgewhlt.");
    } else {
        final ResultContainer result = new ResultContainer();
        for (ZeugnisFormular zeugnisFormular : formulare) {
            result.addResultContainer(zeugnisInitialierungsService.initZeugnis(zeugnisFormular));
        }
        redirectAttributes.addFlashAttribute("result", result);
    }
    return URL.redirect(URL.Configuration.INIT_ZEUGNISSE);
}

From source file:com.alibaba.otter.node.etl.extract.extractor.GroupExtractor.java

@Override
public void extract(DbBatch dbBatch) throws ExtractException {
    Assert.notNull(dbBatch);//from  ww w .  j  a  va 2  s  .  co m
    Assert.notNull(dbBatch.getRowBatch());

    Pipeline pipeline = getPipeline(dbBatch.getRowBatch().getIdentity().getPipelineId());
    List<DataMediaPair> dataMediaPairs = pipeline.getPairs();

    /**
     * Key = TableId<br>
     * Value = a List of this tableId's column need to sync<br>
     */
    Map<Long, List<ColumnGroup>> groupColumns = new HashMap<Long, List<ColumnGroup>>();

    for (DataMediaPair dataMediaPair : dataMediaPairs) {
        List<ColumnGroup> columnGroups = dataMediaPair.getColumnGroups();
        if (!CollectionUtils.isEmpty(columnGroups)) {
            groupColumns.put(dataMediaPair.getSource().getId(), columnGroups);
        }
    }

    List<EventData> eventDatas = dbBatch.getRowBatch().getDatas();
    for (EventData eventData : eventDatas) {
        if (eventData.getEventType().isDdl()) {
            continue;
        }

        List<ColumnGroup> columnGroups = groupColumns.get(eventData.getTableId());
        if (!CollectionUtils.isEmpty(columnGroups)) {
            for (ColumnGroup columnGroup : columnGroups) {
                if (columnGroup != null && !CollectionUtils.isEmpty(columnGroup.getColumnPairs())) {
                    groupFilter(eventData, columnGroup);
                }
            }
        }
    }
}

From source file:com.frank.search.solr.core.schema.SolrSchemaResolver.java

protected SchemaDefinition.FieldDefinition createFieldDefinitionForProperty(SolrPersistentProperty property) {

    if (property == null || property.isReadonly() || property.isTransient()) {
        return null;
    }//from  ww w  . j  a va2  s  .c  om

    SchemaDefinition.FieldDefinition definition = new SchemaDefinition.FieldDefinition(property.getFieldName());
    definition.setMultiValued(property.isMultiValued());
    definition.setIndexed(property.isSearchable());
    definition.setStored(property.isStored());
    definition.setType(property.getSolrTypeName());
    definition.setDefaultValue(property.getDefaultValue());
    definition.setRequired(property.isRequired());

    Collection<String> copyFields = property.getCopyFields();
    if (!CollectionUtils.isEmpty(copyFields)) {
        definition.setCopyFields(copyFields);
    }

    return definition;
}

From source file:cognition.pipeline.service.anonymisation.AnonymisationService.java

private void traverseAndAnonymise(Node node, Individual individual) {
    if (node == null) {
        return;/*w  w  w. ja v a 2  s . co m*/
    }

    if (node instanceof TextNode) {
        TextNode textNode = (TextNode) node;
        textNode.text(pseudonymiseAll(individual, textNode.text()));
    }

    if (CollectionUtils.isEmpty(node.childNodes())) {
        return;
    }

    for (Node child : node.childNodes()) {
        traverseAndAnonymise(child, individual);
    }
}

From source file:nl.surfnet.coin.teams.service.impl.TeamInviteServiceHibernateImpl.java

/**
 * {@inheritDoc}// w  ww .j a v a 2s.  c om
 */
@Override
public Invitation findInvitationByInviteId(String invitationId) {
    cleanupExpiredInvitations();
    long twoWeeksAgo = (new Date().getTime()) - TWO_WEEKS;
    List<Invitation> invitations = findByCriteria(Restrictions.eq("invitationHash", invitationId),
            Restrictions.ge("timestamp", twoWeeksAgo));
    return CollectionUtils.isEmpty(invitations) ? null : invitations.get(0);
}

From source file:com.fredhopper.core.connector.index.generate.validator.TextAttributeValidator.java

@Override
protected void validateValue(final FhAttributeData attribute, final List<Violation> violations) {
    final Table<Optional<String>, Optional<Locale>, String> values = attribute.getValues();
    final Map<Optional<Locale>, String> valueMap = values.row(Optional.empty());
    if (CollectionUtils.isEmpty(valueMap) || valueMap.entrySet().size() != 1
            || !valueMap.containsKey(Optional.empty())) {
        rejectValue(attribute, violations, "The \"text\" attribute value cannot be localized.");
        return;/*w  w w. j  ava2s.  c  o  m*/
    }

    final String value = valueMap.get(Optional.empty());
    if (StringUtils.isBlank(value)) {
        rejectValue(attribute, violations, "The \"text\" attribute value must not be blank.");
    }
}

From source file:com.icfcc.cache.annotation.AbstractCachingConfiguration.java

/**
 * Determine which {@code CacheManager} bean to use. Prefer the result of
 * {@link CachingConfigurer#cacheManager()} over any by-type matching. If none, fall
 * back to by-type matching on {@code CacheManager}.
 * @throws IllegalArgumentException if no CacheManager can be found; if more than one
 * CachingConfigurer implementation exists; if multiple CacheManager beans and no
 * CachingConfigurer exists to disambiguate.
 *//*from ww  w.jav  a2s  .c o m*/
//@PostConstruct
protected void reconcileCacheManager() {
    if (!CollectionUtils.isEmpty(cachingConfigurers)) {
        int nConfigurers = cachingConfigurers.size();
        if (nConfigurers > 1) {
            throw new IllegalStateException(nConfigurers + " implementations of "
                    + "CachingConfigurer were found when only 1 was expected. "
                    + "Refactor the configuration such that CachingConfigurer is "
                    + "implemented only once or not at all.");
        }
        CachingConfigurer cachingConfigurer = cachingConfigurers.iterator().next();
        this.cacheManager = cachingConfigurer.cacheManager();
        this.keyGenerator = cachingConfigurer.keyGenerator();
    } else if (!CollectionUtils.isEmpty(cacheManagerBeans)) {
        int nManagers = cacheManagerBeans.size();
        if (nManagers > 1) {
            throw new IllegalStateException(nManagers + " beans of type CacheManager "
                    + "were found when only 1 was expected. Remove all but one of the "
                    + "CacheManager bean definitions, or implement CachingConfigurer "
                    + "to make explicit which CacheManager should be used for "
                    + "annotation-driven cache management.");
        }
        CacheManager cacheManager = cacheManagerBeans.iterator().next();
        this.cacheManager = cacheManager;
        // keyGenerator remains null; will fall back to default within CacheInterceptor
    } else {
        throw new IllegalStateException("No bean of type CacheManager could be found. "
                + "Register a CacheManager bean or remove the @EnableCaching annotation "
                + "from your configuration.");
    }
}

From source file:com.alibaba.otter.node.etl.extract.extractor.ViewExtractor.java

@Override
public void extract(DbBatch dbBatch) throws ExtractException {
    Assert.notNull(dbBatch);/*from  ww w.j ava2  s .c o  m*/
    Assert.notNull(dbBatch.getRowBatch());

    Pipeline pipeline = getPipeline(dbBatch.getRowBatch().getIdentity().getPipelineId());
    List<DataMediaPair> dataMediaPairs = pipeline.getPairs();

    /**
     * Key = TableId<br>
     * Value = a List of this tableId's column need to sync<br>
     */
    Map<Long, List<ColumnPair>> viewColumnPairs = new HashMap<Long, List<ColumnPair>>();
    Map<Long, ColumnPairMode> viewColumnPairModes = new HashMap<Long, ColumnPairMode>();

    for (DataMediaPair dataMediaPair : dataMediaPairs) {
        List<ColumnPair> columnPairs = dataMediaPair.getColumnPairs();
        // ColumnPairMode
        viewColumnPairModes.put(dataMediaPair.getSource().getId(), dataMediaPair.getColumnPairMode());
        // columnPairs????
        if (!CollectionUtils.isEmpty(columnPairs)) {
            viewColumnPairs.put(dataMediaPair.getSource().getId(), columnPairs);
        }
    }

    List<EventData> eventDatas = dbBatch.getRowBatch().getDatas();
    Set<EventData> removeDatas = new HashSet<EventData>();// set???remove
    for (EventData eventData : eventDatas) {
        if (eventData.getEventType().isDdl()) {
            continue;
        }

        List<ColumnPair> columns = viewColumnPairs.get(eventData.getTableId());
        if (!CollectionUtils.isEmpty(columns)) {
            // ??Column
            ColumnPairMode mode = viewColumnPairModes.get(eventData.getTableId());
            eventData.setColumns(columnFilter(eventData.getColumns(), columns, mode));
            eventData.setKeys(columnFilter(eventData.getKeys(), columns, mode));
            if (!CollectionUtils.isEmpty(eventData.getOldKeys())) {
                eventData.setOldKeys(columnFilter(eventData.getOldKeys(), columns, mode));
            }

            if (CollectionUtils.isEmpty(eventData.getKeys())) { // 
                throw new ExtractException(String.format(
                        "eventData after viewExtractor has no pks , pls check! identity:%s, new eventData:%s",
                        dbBatch.getRowBatch().getIdentity().toString(), eventData.toString()));
            }

            // insert?view??
            // delete: eventData??
            // update: ?(???)????sql
            if (eventData.getEventType().isUpdate()
                    && (CollectionUtils.isEmpty(eventData.getColumns())
                            || CollectionUtils.isEmpty(eventData.getUpdatedColumns()))
                    && CollectionUtils.isEmpty(eventData.getOldKeys())) {
                // ??????
                removeDatas.add(eventData);
            }
        }

    }

    if (!CollectionUtils.isEmpty(removeDatas)) {
        eventDatas.removeAll(removeDatas);
    }
}

From source file:com.fredhopper.core.connector.index.generate.validator.IntAttributeValidator.java

@Override
protected void validateValue(final FhAttributeData attribute, final List<Violation> violations) {
    final Table<Optional<String>, Optional<Locale>, String> values = attribute.getValues();
    final Map<Optional<Locale>, String> valueMap = values.row(Optional.empty());
    if (CollectionUtils.isEmpty(valueMap) || valueMap.entrySet().size() != 1
            || !valueMap.containsKey(Optional.empty())) {
        rejectValue(attribute, violations, "The \"int\" attribute value cannot be localized.");
        return;/*from  w  w  w.  ja va 2s .  c  o m*/
    }

    final String value = valueMap.get(Optional.empty());
    try {
        if (StringUtils.isBlank(value) || !(Integer.parseInt(value) > 0
                && Double.valueOf(Integer.MAX_VALUE).compareTo(Double.valueOf(value)) > 0)) {
            rejectValue(attribute, violations,
                    "The \"int\" attribute value is not in the supported value range.");
        }
    } catch (final NumberFormatException ex) {
        rejectValue(attribute, violations, "The \"int\" attribute value does not have the appropriate format.");
    }
}