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:co.runrightfast.core.application.event.AppEvent.java

@Override
public String toString() {
    final MoreObjects.ToStringHelper toStringHelper = MoreObjects.toStringHelper(this)
            .add("timestamp", getTimestamp()).add("event", event).add("eventLevel", eventLevel);

    if (StringUtils.isNotBlank(message)) {
        toStringHelper.add("message", message);
    }/*from w  w w  .j a  va2s .c om*/

    if (CollectionUtils.isNotEmpty(tags)) {
        toStringHelper.add("tags", tags.stream().collect(Collectors.joining(",")));
    }

    if (data != null) {
        toStringHelper.add("data", data.getType());
    }

    if (exception != null) {
        toStringHelper.add("exception", ExceptionUtils.getStackTrace(exception));
    }

    return toStringHelper.toString();

}

From source file:com.adguard.filter.rules.FilterRule.java

/**
 * Checks if this rule is permitted for the specified domain
 *
 * @param domainName Domain name// w  ww. j  a v a 2s. co  m
 * @return true if rule is permitted
 */
public boolean isPermitted(String domainName) {
    if (StringUtils.isEmpty(domainName)) {
        return false;
    }

    if (UrlUtils.isDomainOrSubDomain(domainName, restrictedDomains)) {
        return false;
    }

    //noinspection SimplifiableIfStatement
    if (CollectionUtils.isNotEmpty(permittedDomains)) {
        // If permitted domains set -- this rule work for permitted domains ONLY
        return UrlUtils.isDomainOrSubDomain(domainName, permittedDomains);
    }

    return true;
}

From source file:io.kodokojo.service.redis.RedisProjectStore.java

private void fillStackConfigurationBrick(StackConfiguration stackConfiguration) {
    List<BrickConfiguration> brickConfigurationUpdated = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(stackConfiguration.getBrickConfigurations())) {
        brickConfigurationUpdated//from  ww  w  . j  av a  2 s.c o  m
                .addAll(stackConfiguration.getBrickConfigurations().stream().map(brickConfiguration -> {
                    Brick brick = brickFactory.createBrick(brickConfiguration.getName());
                    return new BrickConfiguration(brick, brickConfiguration.getName(),
                            brickConfiguration.getType(), brickConfiguration.getUrl(), brick.getVersion(),
                            brickConfiguration.isWaitRunning());
                }).collect(Collectors.toList()));
    }
    stackConfiguration.getBrickConfigurations().clear();
    stackConfiguration.getBrickConfigurations().addAll(brickConfigurationUpdated);
}

From source file:com.epam.catgenome.dao.DaoHelper.java

@Transactional(propagation = Propagation.MANDATORY)
public Long createTempList(final Collection<? extends BaseEntity> list) {
    Assert.isTrue(CollectionUtils.isNotEmpty(list));
    return createTempList(createListId(), list);
}

From source file:io.github.swagger2markup.internal.document.builder.PathsDocumentBuilder.java

private void buildsPathsSection(Map<String, Path> paths) {
    Set<PathOperation> pathOperations = toPathOperationsSet(paths);
    if (CollectionUtils.isNotEmpty(pathOperations)) {
        if (config.getPathsGroupedBy() == GroupBy.AS_IS) {
            for (PathOperation operation : pathOperations) {
                buildOperation(operation);
            }//from   ww w.j av  a 2s  .co  m
        } else {
            Multimap<String, PathOperation> operationsGroupedByTag = TagUtils.groupOperationsByTag(
                    pathOperations, config.getTagOrdering(), config.getOperationOrdering());
            Map<String, Tag> tagsMap = convertTagsListToMap(globalContext.getSwagger().getTags());
            for (String tagName : operationsGroupedByTag.keySet()) {
                this.markupDocBuilder.sectionTitleWithAnchorLevel2(WordUtils.capitalize(tagName),
                        tagName + "_resource");

                Optional<String> tagDescription = getTagDescription(tagsMap, tagName);
                if (tagDescription.isPresent()) {
                    this.markupDocBuilder.paragraph(tagDescription.get());
                }

                for (PathOperation operation : operationsGroupedByTag.get(tagName)) {
                    buildOperation(operation);
                }
            }
        }
    }
}

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

private Element getArPrElement(final Element ar) {
    final List<Element> arPrElements = ar.getContent(Filters.element(PPTXDocument.RPR_ELEMENT, getNamespace()));
    Element arPr = null;/*from w w w  . j  a  v  a  2  s  .  c  om*/
    if (CollectionUtils.isNotEmpty(arPrElements)) {
        arPr = arPrElements.get(0).clone();
        arPr.removeAttribute("b", getNamespace());
        arPr.removeAttribute("i", getNamespace());
        arPr.removeAttribute("u", getNamespace());
    }
    return arPr;
}

From source file:io.cloudslang.lang.compiler.validator.CompileValidatorImpl.java

private boolean isForLoop(Step step, List<String> breakValuesList) {
    Serializable forData = step.getPreStepActionData().get(SlangTextualKeys.FOR_KEY);
    return (forData != null) && CollectionUtils.isNotEmpty(breakValuesList);
}

From source file:com.haulmont.cuba.core.sys.PersistenceSecurityImpl.java

@Override
@SuppressWarnings("unchecked")
public void restoreFilteredData(Entity entity) {
    MetaClass metaClass = metadata.getClassNN(entity.getClass());
    String storeName = metadataTools.getStoreName(metaClass);
    EntityManager entityManager = persistence.getEntityManager(storeName);

    Multimap<String, Object> filtered = BaseEntityInternalAccess.getFilteredData(entity);
    if (filtered == null) {
        return;//from www. jav  a 2 s .c o  m
    }

    for (Map.Entry<String, Collection<Object>> entry : filtered.asMap().entrySet()) {
        MetaProperty property = metaClass.getPropertyNN(entry.getKey());
        Collection filteredIds = entry.getValue();

        if (property.getRange().isClass() && CollectionUtils.isNotEmpty(filteredIds)) {
            Class entityClass = property.getRange().asClass().getJavaClass();
            Class propertyClass = property.getJavaType();
            if (Collection.class.isAssignableFrom(propertyClass)) {
                Collection currentCollection = entity.getValue(property.getName());
                if (currentCollection == null) {
                    throw new RowLevelSecurityException(format(
                            "Could not restore an object to currentValue because it is null [%s]. Entity [%s].",
                            property.getName(), metaClass.getName()), metaClass.getName());
                }

                for (Object entityId : filteredIds) {
                    Entity reference = entityManager.getReference((Class<Entity>) entityClass, entityId);
                    //we ignore situations when the currentValue is immutable
                    currentCollection.add(reference);
                }
            } else if (Entity.class.isAssignableFrom(propertyClass)) {
                Object entityId = filteredIds.iterator().next();
                Entity reference = entityManager.getReference((Class<Entity>) entityClass, entityId);
                //we ignore the situation when the field is read-only
                entity.setValue(property.getName(), reference);
            }
        }
    }
}

From source file:com.baifendian.swordfish.dao.mapper.StreamingResultMapperProvider.java

/**
 * ???//  w  w  w .j  a  va 2 s.  c o  m
 *
 * @param parameter
 * @return
 */
public String findByMultiCondition(Map<String, Object> parameter) {
    List<Integer> status = (List<Integer>) parameter.get("status");
    String name = (String) parameter.get("name");

    Date startDate = (Date) parameter.get("startDate");
    Date endDate = (Date) parameter.get("endDate");

    SQL sql = constructCommonDetailSQL().WHERE("s.project_id = #{projectId}");

    if (startDate != null) {
        sql = sql.WHERE("schedule_time >= #{startDate}");
    }

    if (endDate != null) {
        sql = sql.WHERE("schedule_time < #{endDate}");
    }

    // ?
    if (StringUtils.isNotEmpty(name)) {
        sql = sql.WHERE("s.name like '" + name + "%'");
    }

    if (CollectionUtils.isNotEmpty(status)) {
        sql = sql.WHERE("`status` in (" + StringUtils.join(status, ",") + ")");
    }

    String subClause = sql.toString();

    String sqlClause = new SQL() {
        {
            SELECT("*");

            FROM("(" + subClause + ") e_f");
        }
    }.toString() + " order by schedule_time DESC limit #{start},#{limit}";

    return sqlClause;
}

From source file:com.haulmont.cuba.web.app.ui.core.settings.SettingsWindow.java

protected List<MenuItem> collectPermittedScreens(List<MenuItem> menuItems) {
    List<MenuItem> collectedItems = new ArrayList<>();

    for (MenuItem item : menuItems) {
        if (!item.isPermitted(userSession))
            continue;

        if (StringUtils.isNotEmpty(item.getScreen())) {
            collectedItems.add(item);/*  ww w  .  jav a  2  s  .com*/
        }

        if (CollectionUtils.isNotEmpty(item.getChildren())) {
            collectedItems.addAll(collectPermittedScreens(item.getChildren()));
        }
    }

    return collectedItems;
}