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.juiser.spring.boot.config.JuiserDefaultAutoConfiguration.java

@Bean
@ConditionalOnMissingBean(name = "juiserForwardedUserFilter")
public FilterRegistrationBean juiserForwardedUserFilter() {

    ForwardedUserFilterConfig cfg = juiserForwardedUserFilterConfig();

    Filter filter = new SpringForwardedUserFilter(forwardedHeaderConfig().getName(), juiserRequestUserFactory(),
            cfg.getRequestAttributeNames());

    FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(filter);/*from  w w  w  .j a  v  a 2 s  .  co m*/
    bean.setEnabled(cfg.isEnabled());
    bean.setMatchAfter(cfg.isMatchAfter());
    bean.setOrder(cfg.getOrder());

    Set<DispatcherType> dispatcherTypes = cfg.getDispatcherTypes();
    if (!CollectionUtils.isEmpty(dispatcherTypes)) {
        bean.setDispatcherTypes(EnumSet.copyOf(dispatcherTypes));
    }
    Set<String> set = cfg.getServletNames();
    if (!CollectionUtils.isEmpty(set)) {
        bean.setServletNames(set);
    }
    set = cfg.getUrlPatterns();
    if (!CollectionUtils.isEmpty(set)) {
        bean.setUrlPatterns(set);
    }

    return bean;
}

From source file:com.gopivotal.spring.xd.module.jdbc.JdbcTasklet.java

/**
 * Execute the {@link #setSql(String) SQL query} provided. If the query starts with "select" (case insensitive) the
 * result is a list of maps, which is logged and added to the step execution exit status. Otherwise the query is
 * executed and the result is an indication, also in the exit status, of the number of rows updated.
 *///ww  w . j a v  a 2s  .c  o m
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {

    StepExecution stepExecution = chunkContext.getStepContext().getStepExecution();
    ExitStatus exitStatus = stepExecution.getExitStatus();

    String msg = "";
    if (StringUtils.hasText(sql)) {
        msg = runCommand(chunkContext.getStepContext(), sql);
    } else if (!CollectionUtils.isEmpty(scripts)) {
        msg = runScripts(chunkContext, scripts, null);
    }

    stepExecution.setExitStatus(exitStatus.addExitDescription(msg));
    return RepeatStatus.FINISHED;
}

From source file:com.formkiq.core.form.service.FormValidatorServiceImpl.java

@Override
public Map<String, String> validate(final ArchiveDTO archive) {

    Workflow workflow = archive.getWorkflow();
    Map<String, String> errors = validate(workflow);

    if (errors.isEmpty()) {

        for (FormJSON form : archive.getForms().values()) {

            if (isEmpty(form.getName())) {
                errors.put("name", "Form name is required");
            }//w w  w  . java  2s  .  co m

            List<FormJSONSection> sections = form.getSections();

            if (CollectionUtils.isEmpty(sections)) {
                errors.put("section", "At least 1 section is required");
            }

            if (!CollectionUtils.isEmpty(sections)) {
                for (FormJSONSection section : sections) {
                    if (CollectionUtils.isEmpty(section.getFields())) {
                        errors.put("steps", "At least 1 field is required");
                    }
                }
            }

            if (!errors.isEmpty()) {
                break;
            }
        }
    }

    if (errors.isEmpty() && isEmpty(workflow.getParentUUID())) {

        if (isEmpty(workflow.getLabel1form())) {
            errors.put("label1form", "Workflow must have at least 1 Label.");
        }

        if (isEmpty(workflow.getLabel1field())) {
            errors.put("label1field", "Label Field on Workflow must be is required");
        }
    }

    return errors;
}

From source file:com.civilizer.web.handler.ResourceHttpRequestHandler.java

public void afterPropertiesSet() throws Exception {
    if (logger.isWarnEnabled() && CollectionUtils.isEmpty(this.locations)) {
        logger.warn("Locations list is empty. No resources will be served");
    }/*from  w w w.  j a  v  a 2s  . c  om*/
}

From source file:ua.com.manometer.jasperreports.JasperReportsMultiFormatView.java

/**
 * Set the mappings of format discriminators to view class names.
 * The default mappings are:/*from ww w.ja va  2  s. c  om*/
 * <p><ul>
 * <li><code>csv</code> - <code>JasperReportsCsvView</code></li>
 * <li><code>html</code> - <code>JasperReportsHtmlView</code></li>
 * <li><code>pdf</code> - <code>JasperReportsPdfView</code></li>
 * <li><code>xls</code> - <code>JasperReportsXlsView</code></li>
 * </ul>
 */
public void setFormatMappings(Map<String, Class<? extends AbstractJasperReportsView>> formatMappings) {
    if (CollectionUtils.isEmpty(formatMappings)) {
        throw new IllegalArgumentException("'formatMappings' must not be empty");
    }
    this.formatMappings = formatMappings;
}

From source file:com.frank.search.solr.repository.query.SolrQueryMethod.java

/**
 * @return true if {@link Facet#pivotFields()} is not empty
 *///from  w w w .j  a  v a  2  s .c o m
public boolean hasPivotFields() {
    if (hasFacetAnnotation()) {
        return !CollectionUtils.isEmpty(getPivotFields());
    }
    return false;
}

From source file:com.alibaba.otter.shared.arbitrate.impl.setl.zookeeper.monitor.AbstractStageListener.java

/**
 * ???processIds?reply queue?processIds//w ww.ja  v  a 2s.  c  om
 */
protected synchronized void compareReply(List<Long> processIds) {
    Object[] replyIds = replyProcessIds.toArray();
    for (Object replyId : replyIds) {
        if (processIds.contains((Long) replyId) == false) { // reply id??processId
            // ?Listener???processprocessIdreply
            // ?processIds??process??
            if (CollectionUtils.isEmpty(processIds) == false) {
                Long processId = processIds.get(0);
                if (processId > (Long) replyId) { // ??processIdreplyId, processId
                    processTermined((Long) replyId); // ?
                }
            }
        }
    }
}

From source file:org.wallride.web.controller.admin.article.ArticleEditForm.java

public ArticleUpdateRequest buildArticleUpdateRequest() {
    List<CustomFieldValueEditForm> customFieldValues_ = new ArrayList<>();
    if (!CollectionUtils.isEmpty(customFieldValues)) {
        customFieldValues_ = customFieldValues.stream().filter(v -> v.getCustomFieldId() != 0)
                .collect(Collectors.toList());
    }/*  w  ww .j  a  va 2  s .co m*/

    ArticleUpdateRequest.Builder builder = new ArticleUpdateRequest.Builder();
    return builder.id(id).code(code).coverId(coverId).title(title).body(body).authorId(authorId).date(date)
            .categoryIds(categoryIds).tags(tags).relatedPostIds(relatedPostIds).seoTitle(seoTitle)
            .seoDescription(seoDescription).seoKeywords(seoKeywords).customFieldValues(customFieldValues_)
            .language(language).build();
}

From source file:com.alibaba.otter.manager.biz.remote.impl.ConfigRemoteServiceImpl.java

public boolean notifyChannel(final Channel channel) {
    Assert.notNull(channel);/*  w  w w.  j a v a 2  s.  c  o  m*/
    // ?Node
    NotifyChannelEvent event = new NotifyChannelEvent();
    event.setChannel(channel);

    Set<String> addrsSet = new HashSet<String>();

    // ?otternode
    // List<Node> nodes = nodeService.listAll();
    // for (Node node : nodes) {
    // if (node.getStatus().isStart() &&
    // StringUtils.isNotEmpty(node.getIp()) && node.getPort() != 0) {
    // final String addr = node.getIp() + ":" + node.getPort();
    // addrsList.add(addr);
    // }
    // }

    // ?pipelinenode
    for (Pipeline pipeline : channel.getPipelines()) {
        List<Node> nodes = new ArrayList<Node>();
        nodes.addAll(pipeline.getSelectNodes());
        nodes.addAll(pipeline.getExtractNodes());
        nodes.addAll(pipeline.getLoadNodes());
        for (Node node : nodes) {
            if (node.getStatus().isStart() && StringUtils.isNotEmpty(node.getIp()) && node.getPort() != 0) {
                String addr = node.getIp() + ":" + node.getPort();
                if (node.getParameters().getUseExternalIp()) {
                    addr = node.getParameters().getExternalIp() + ":" + node.getPort();
                }
                addrsSet.add(addr);
            }
        }
    }

    List<String> addrsList = new ArrayList<String>(addrsSet);
    if (CollectionUtils.isEmpty(addrsList) && channel.getStatus().isStart()) {
        throw new ManagerException("no live node for notifyChannel");
    } else if (CollectionUtils.isEmpty(addrsList)) {
        // ???
        return true;
    } else {
        Collections.shuffle(addrsList);// ???????
        try {
            String[] addrs = addrsList.toArray(new String[addrsList.size()]);
            List<Boolean> result = (List<Boolean>) communicationClient.call(addrs, event); // ??
            logger.info("## notifyChannel to [{}] channel[{}] result[{}]",
                    new Object[] { ArrayUtils.toString(addrs), channel.toString(), result });

            boolean flag = true;
            for (Boolean f : result) {
                flag &= f;
            }

            return flag;
        } catch (Exception e) {
            logger.error("## notifyChannel error!", e);
            throw new ManagerException(e);
        }
    }
}

From source file:com.monarchapis.driver.spring.rest.ApiErrorResponseEntityExceptionHandler.java

protected ResponseEntity<Object> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex,
        HttpHeaders headers, HttpStatus status, WebRequest request) {
    List<MediaType> mediaTypes = ex.getSupportedMediaTypes();

    if (!CollectionUtils.isEmpty(mediaTypes)) {
        headers.setAccept(mediaTypes);/*from www. j  av  a2  s  . co  m*/
    }

    return errorResponse("mediaTypeNotSupported", headers);
}