Example usage for org.apache.commons.collections4 CollectionUtils isNotEmpty

List of usage examples for org.apache.commons.collections4 CollectionUtils isNotEmpty

Introduction

In this page you can find the example usage for org.apache.commons.collections4 CollectionUtils isNotEmpty.

Prototype

public static boolean isNotEmpty(final Collection<?> coll) 

Source Link

Document

Null-safe check if the specified collection is not empty.

Usage

From source file:io.github.swagger2markup.internal.document.PathsDocument.java

/**
 * Builds the paths section. Groups the paths either as-is, by tags or using regex.
 *
 * @param paths the Swagger paths/*  w  w w  .ja v a  2  s  .  com*/
 */
private void buildsPathsSection(MarkupDocBuilder markupDocBuilder, Map<String, Path> paths) {
    List<PathOperation> pathOperations = PathUtils.toPathOperationsList(paths, getBasePath(),
            config.getOperationOrdering());
    if (CollectionUtils.isNotEmpty(pathOperations)) {
        if (config.getPathsGroupedBy() == GroupBy.AS_IS) {
            pathOperations.forEach(operation -> buildOperation(markupDocBuilder, operation, config));
        } else if (config.getPathsGroupedBy() == GroupBy.TAGS) {
            Validate.notEmpty(context.getSwagger().getTags(),
                    "Tags must not be empty, when operations are grouped by tags");
            // Group operations by tag
            Multimap<String, PathOperation> operationsGroupedByTag = TagUtils
                    .groupOperationsByTag(pathOperations, config.getOperationOrdering());

            Map<String, Tag> tagsMap = TagUtils.toSortedMap(context.getSwagger().getTags(),
                    config.getTagOrdering());

            tagsMap.forEach((String tagName, Tag tag) -> {
                markupDocBuilder.sectionTitleWithAnchorLevel2(WordUtils.capitalize(tagName),
                        tagName + "_resource");
                String description = tag.getDescription();
                if (StringUtils.isNotBlank(description)) {
                    markupDocBuilder.paragraph(description);
                }
                operationsGroupedByTag.get(tagName)
                        .forEach(operation -> buildOperation(markupDocBuilder, operation, config));

            });
        } else if (config.getPathsGroupedBy() == GroupBy.REGEX) {
            Validate.notNull(config.getHeaderPattern(),
                    "Header regex pattern must not be empty when operations are grouped using regex");

            Pattern headerPattern = config.getHeaderPattern();
            Multimap<String, PathOperation> operationsGroupedByRegex = RegexUtils
                    .groupOperationsByRegex(pathOperations, headerPattern);
            Set<String> keys = operationsGroupedByRegex.keySet();
            String[] sortedHeaders = RegexUtils.toSortedArray(keys);

            for (String header : sortedHeaders) {
                markupDocBuilder.sectionTitleWithAnchorLevel2(WordUtils.capitalize(header),
                        header + "_resource");
                operationsGroupedByRegex.get(header)
                        .forEach(operation -> buildOperation(markupDocBuilder, operation, config));
            }
        }
    }
}

From source file:com.movies.entities.Movie.java

public List<Genre> getGenresList() {
    if (CollectionUtils.isEmpty(genresList) && CollectionUtils.isNotEmpty(genres)) {
        genresList = new ArrayList<>(genres);
    }/* w ww. ja v  a  2 s. c  o  m*/
    return genresList;
}

From source file:com.goodhuddle.huddle.service.impl.PetitionServiceImpl.java

@Override
@Transactional(readOnly = false)/* w  w  w  .jav a 2 s .co  m*/
public Petition updatePetition(UpdatePetitionRequest request) {
    Petition petition = petitionRepository.findByHuddleAndId(huddleService.getHuddle(), request.getId());

    petition.update(request.getName(), request.getDescription(), request.getSubject(), request.getContent(),
            request.getPetitionEmailTemplate(), request.getThankyouEmailTemplate(),
            request.getAdminEmailAddresses(), request.getAdminEmailTemplate());

    petitionRepository.save(petition);

    petitionTargetRepository.deleteByPetition(petition);
    if (CollectionUtils.isNotEmpty(request.getTargets())) {
        for (AbstractPetitionRequest.Target target : request.getTargets()) {
            petitionTargetRepository.save(new PetitionTarget(petition, target.getName(), target.getEmail()));
        }
    }

    log.info("Petition with ID {} updated", request.getId());
    return petition;
}

From source file:io.github.swagger2markup.internal.component.DefinitionComponent.java

/**
 * Builds inline schema definitions//from   w ww .jav a 2 s  . co  m
 *
 * @param markupDocBuilder the docbuilder do use for output
 * @param definitions      all inline definitions to display
 * @param uniquePrefix     unique prefix to prepend to inline object names to enforce unicity
 */
private void inlineDefinitions(MarkupDocBuilder markupDocBuilder, List<ObjectType> definitions,
        String uniquePrefix) {
    if (CollectionUtils.isNotEmpty(definitions)) {
        for (ObjectType definition : definitions) {
            addInlineDefinitionTitle(definition.getName(), definition.getUniqueName(), markupDocBuilder);

            List<ObjectType> localDefinitions = new ArrayList<>();
            propertiesTableComponent.apply(markupDocBuilder, new PropertiesTableComponent.Parameters(
                    definition.getProperties(), uniquePrefix, localDefinitions));
            for (ObjectType localDefinition : localDefinitions)
                inlineDefinitions(markupDocBuilder, Collections.singletonList(localDefinition),
                        localDefinition.getUniqueName());
        }
    }
}

From source file:com.jkoolcloud.tnt4j.streams.parsers.ActivityParser.java

/**
 * Sets the value for the field in the specified activity entity.
 * <p>//www .  j ava2s  . c om
 * If field has stacked parser defined, then field value is parsed into separate activity using stacked parser. If
 * field can be parsed by stacked parser, produced activity can be merged or added as a child into specified
 * (parent) activity depending on stacked parser reference 'aggregation' attribute value.
 *
 * @param stream
 *            parent stream
 * @param ai
 *            activity object whose field is to be set
 * @param field
 *            field to apply value to
 * @param value
 *            value to apply for this field
 * @throws IllegalStateException
 *             if parser has not been properly initialized
 * @throws ParseException
 *             if an error parsing the specified value
 * @see #parse(TNTInputStream, Object)
 */
protected void applyFieldValue(TNTInputStream<?, ?> stream, ActivityInfo ai, ActivityField field, Object value)
        throws IllegalStateException, ParseException {

    applyFieldValue(ai, field, value);

    if (CollectionUtils.isNotEmpty(field.getStackedParsers())) {
        value = Utils.cleanActivityData(value);
        for (ActivityField.ParserReference parserRef : field.getStackedParsers()) {
            // TODO: tags
            boolean applied = applyStackedParser(stream, ai, parserRef, value);

            if (applied) {
                break;
            }
        }
    }
}

From source file:edu.cornell.kfs.vnd.document.service.impl.CUVendorServiceImpl.java

private List<VendorRoutingComparable> convertToRountingComparable(
        List<? extends PersistableBusinessObjectBase> vendorCollection) {
    List<VendorRoutingComparable> retList = new ArrayList<VendorRoutingComparable>();
    if (CollectionUtils.isNotEmpty(vendorCollection)) {
        for (PersistableBusinessObjectBase pbo : vendorCollection) {
            retList.add((VendorRoutingComparable) pbo);
        }/*from w  w w . j  a  v a 2  s  .  c o m*/
    }
    return retList;
}

From source file:jodtemplate.pptx.postprocessor.StylePostprocessor.java

private void injectRemainsInDocument(final List<Element> remains, final Element ap, final Element apPr,
        final int apIndex) {
    if (CollectionUtils.isNotEmpty(remains)) {
        final Element txBody = ap.getParentElement();
        final Element apWithRemains = new Element(PPTXDocument.P_ELEMENT, getNamespace());
        if (apPr != null) {
            apWithRemains.addContent(apPr);
        }//ww w.  ja  v  a  2  s. c o  m
        apWithRemains.addContent(remains);
        txBody.addContent(apIndex, apWithRemains);
    }
}

From source file:com.mirth.connect.client.ui.dependencies.ChannelDependenciesWarningDialog.java

private void setTextPane(ChannelTask task, OrderedChannels orderedChannels, List<Set<String>> orderedChannelIds,
        Set<String> selectedChannelIds, boolean boldAdditional) {
    Map<String, DashboardStatus> statusMap = null;
    if (task != ChannelTask.DEPLOY) {
        statusMap = new HashMap<String, DashboardStatus>();
        if (PlatformUI.MIRTH_FRAME.status != null) {
            for (DashboardStatus dashboardStatus : PlatformUI.MIRTH_FRAME.status) {
                statusMap.put(dashboardStatus.getChannelId(), dashboardStatus);
            }//from w w  w.j  av  a2s  . c o m
        }
    }

    StringBuilder builder = new StringBuilder("<html><div>");

    if (CollectionUtils.isNotEmpty(orderedChannels.getUnorderedIds())) {
        builder.append("&nbsp;Independent:&nbsp;");

        for (Iterator<String> it = orderedChannels.getUnorderedIds().iterator(); it.hasNext();) {
            String channelId = it.next();
            String channelName = null;
            builder.append("<b>");

            if (task != ChannelTask.DEPLOY) {
                DashboardStatus dashboardStatus = statusMap.get(channelId);
                if (dashboardStatus != null) {
                    channelName = dashboardStatus.getName();
                }
            } else {
                ChannelStatus channelStatus = PlatformUI.MIRTH_FRAME.channelPanel.getCachedChannelStatuses()
                        .get(channelId);
                if (channelStatus != null) {
                    channelName = channelStatus.getChannel().getName();
                }
            }

            if (channelName != null) {
                builder.append(channelName.replace(" ", "&nbsp;"));
            } else {
                builder.append(channelId.replace(" ", "&nbsp;"));
            }

            builder.append("</b>");

            if (it.hasNext()) {
                builder.append(",&nbsp;");
            }
        }

        builder.append("<br/>");
    }

    for (int i = 0; i < orderedChannelIds.size(); i++) {
        Set<String> set = orderedChannelIds.get(i);

        builder.append("&nbsp;").append(i + 1).append(".&nbsp;");

        for (Iterator<String> it = set.iterator(); it.hasNext();) {
            String channelId = it.next();
            String channelName = null;

            if (boldAdditional || selectedChannelIds.contains(channelId)) {
                builder.append("<b>");
            }

            if (task != ChannelTask.DEPLOY) {
                DashboardStatus dashboardStatus = statusMap.get(channelId);
                if (dashboardStatus != null) {
                    channelName = dashboardStatus.getName();
                }
            } else {
                ChannelStatus channelStatus = PlatformUI.MIRTH_FRAME.channelPanel.getCachedChannelStatuses()
                        .get(channelId);
                if (channelStatus != null) {
                    channelName = channelStatus.getChannel().getName();
                }
            }

            if (channelName != null) {
                builder.append(channelName.replace(" ", "&nbsp;"));
            } else {
                builder.append(channelId.replace(" ", "&nbsp;"));
            }

            if (boldAdditional || selectedChannelIds.contains(channelId)) {
                builder.append("</b>");
            }

            if (it.hasNext()) {
                builder.append(",&nbsp;");
            }
        }

        if (i < orderedChannelIds.size() - 1) {
            builder.append("<br/>");
        }
    }

    builder.append("</div></html>");
    channelsPane.setText(builder.toString());
    channelsPane.setCaretPosition(0);
}

From source file:co.runrightfast.vertx.orientdb.verticle.OrientDBVerticle.java

private Set<RunRightFastHealthCheck> oDatabaseDocumentTxHealthChecks() {
    ServiceUtils.awaitRunning(service);/*from w w w  .j a  v a  2  s .  c  o m*/
    return service.getDatabaseNames().stream().map(name -> {
        final ODatabaseDocumentTxSupplier oDatabaseDocumentTxSupplier = service
                .getODatabaseDocumentTxSupplier(name).get();
        final ODatabaseDocumentTxHealthCheckBuilder healthcheckBuilder = ODatabaseDocumentTxHealthCheck
                .builder().oDatabaseDocumentTxSupplier(oDatabaseDocumentTxSupplier).databaseName(name);
        final Set<Class<? extends DocumentObject>> classes = databaseClassesForHealthCheck.get(name);
        if (CollectionUtils.isNotEmpty(classes)) {
            classes.stream().forEach(healthcheckBuilder::documentObject);
        } else {
            warning.log("oDatabaseDocumentTxHealthChecks", () -> {
                return Json.createObjectBuilder().add("database", name)
                        .add("message", "No OrientDB classes are configured for the healthcheck").build();
            });
        }
        return healthcheckBuilder.build();
    }).map(healthcheck -> {
        return RunRightFastHealthCheck.builder().config(
                healthCheckConfigBuilder().name("EmbeddedOrientDBServiceHealthCheck").severity(FATAL).build())
                .healthCheck(healthcheck).build();
    }).collect(Collectors.toSet());
}

From source file:gov.ca.cwds.cals.service.builder.PlacementHomeEntityAwareDTOBuilder.java

private List<PhoneContactDetail> mapPhoneContactDetails(ApplicantDTO applicantDTO) {
    if (CollectionUtils.isNotEmpty(applicantDTO.getPhones())) {
        return applicantDTO.getPhones().stream().map(phoneNumber -> {
            PhoneContactDetail phoneContactDetail = new PhoneContactDetail();
            phoneContactDetail.setEstblshCd("S");
            phoneContactDetail.setPhoneNo(Long.parseLong(phoneNumber.getNumber()));
            if (StringUtils.isNotEmpty(phoneNumber.getExtension())) {
                phoneContactDetail.setPhextNo(Integer.valueOf(phoneNumber.getExtension()));
            }/*  w  w w.j  a  va 2 s  .  c o  m*/
            phoneContactDetail.setPhnTypCd(phoneNumber.getPhoneType().getCwsShortCode());
            phoneContactDetail.setLstUpdId(PrincipalUtils.getStaffPersonId());
            phoneContactDetail.setLstUpdTs(LocalDateTime.now());
            return phoneContactDetail;
        }).collect(Collectors.toList());
    }
    return Collections.emptyList();
}