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:cgeo.geocaching.CacheListActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setTheme();/*w w  w. ja v a 2 s  .  c  o m*/

    setContentView(R.layout.cacheslist_activity);

    // get parameters
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        type = Intents.getListType(getIntent());
        coords = extras.getParcelable(Intents.EXTRA_COORDS);
    } else {
        extras = new Bundle();
    }
    if (isInvokedFromAttachment()) {
        type = CacheListType.OFFLINE;
        if (coords == null) {
            coords = Geopoint.ZERO;
        }
    }
    if (type == CacheListType.NEAREST) {
        coords = Sensors.getInstance().currentGeo().getCoords();
    }

    setTitle(title);

    // Check whether we're recreating a previously destroyed instance
    if (savedInstanceState != null) {
        // Restore value of members from saved state
        currentFilter = savedInstanceState.getParcelable(STATE_FILTER);
        currentInverseSort = savedInstanceState.getBoolean(STATE_INVERSE_SORT);
        type = CacheListType.values()[savedInstanceState.getInt(STATE_LIST_TYPE, type.ordinal())];
        listId = savedInstanceState.getInt(STATE_LIST_ID);
    }

    initAdapter();

    prepareFilterBar();

    if (type.canSwitch) {
        initActionBarSpinner();
    }

    currentLoader = (AbstractSearchLoader) getSupportLoaderManager().initLoader(type.getLoaderId(), extras,
            this);

    // init
    if (CollectionUtils.isNotEmpty(cacheList)) {
        // currentLoader can be null if this activity is created from a map, as onCreateLoader() will return null.
        if (currentLoader != null && currentLoader.isStarted()) {
            showFooterLoadingCaches();
        } else {
            showFooterMoreCaches();
        }
    }

    if (isInvokedFromAttachment()) {
        listNameMemento.rememberTerm(extras.getString(Intents.EXTRA_NAME));
        importGpxAttachement();
    }
}

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

/**
 * Builds the body parameter section, if {@code Swagger2MarkupConfig.isIsolatedBody()} is true
 *
 * @param operation  the Swagger Operation
 * @param docBuilder the docbuilder do use for output
 * @return a list of inlined types.//from  ww  w. j  a v  a2 s.  c  om
 */
private List<ObjectType> buildBodyParameterSection(PathOperation operation, MarkupDocBuilder docBuilder) {
    List<ObjectType> inlineDefinitions = new ArrayList<>();

    if (config.isFlatBodyEnabled()) {
        List<Parameter> parameters = operation.getOperation().getParameters();
        if (CollectionUtils.isNotEmpty(parameters)) {
            for (Parameter parameter : parameters) {
                if (StringUtils.equals(parameter.getIn(), "body")) {
                    Type type = ParameterUtils.getType(parameter, globalContext.getSwagger().getDefinitions(),
                            new DefinitionDocumentResolverFromOperation());

                    if (!(type instanceof ObjectType)) {
                        type = createInlineType(type, parameter.getName(),
                                operation.getId() + " " + parameter.getName(), inlineDefinitions);
                    }

                    buildSectionTitle(BODY_PARAMETER, docBuilder);
                    if (isNotBlank(parameter.getDescription())) {
                        buildDescriptionParagraph(parameter.getDescription(), docBuilder);
                    }

                    MarkupDocBuilder typeInfos = copyMarkupDocBuilder();
                    typeInfos.italicText(NAME_COLUMN).textLine(COLON + parameter.getName());
                    typeInfos.italicText(FLAGS_COLUMN)
                            .textLine(COLON + (BooleanUtils.isTrue(parameter.getRequired())
                                    ? FLAGS_REQUIRED.toLowerCase()
                                    : FLAGS_OPTIONAL.toLowerCase()));

                    if (!(type instanceof ObjectType)) {
                        typeInfos.italicText(TYPE_COLUMN).textLine(COLON + type.displaySchema(docBuilder));
                    }

                    docBuilder.paragraph(typeInfos.toString(), true);

                    if (type instanceof ObjectType) {
                        inlineDefinitions.addAll(buildPropertiesTable(((ObjectType) type).getProperties(),
                                operation.getId(), new DefinitionDocumentResolverFromOperation(), docBuilder));
                    }
                }
            }
        }
    }

    return inlineDefinitions;
}

From source file:com.jkoolcloud.tnt4j.streams.inputs.TNTInputStream.java

private void removeListeners() {
    if (CollectionUtils.isNotEmpty(streamListeners)) {
        streamListeners.clear();//from w  ww  .ja v  a  2s.  com
    }

    if (CollectionUtils.isNotEmpty(streamTasksListeners)) {
        streamTasksListeners.clear();
    }
}

From source file:com.jkoolcloud.tnt4j.streams.inputs.TNTInputStream.java

private synchronized void shutdownExecutors() {
    if (streamExecutorService == null || streamExecutorService.isShutdown()) {
        return;//  w  ww  .jav  a  2  s.  c  o  m
    }

    streamExecutorService.shutdown();
    try {
        streamExecutorService.awaitTermination(executorsTerminationTimeout, TimeUnit.SECONDS);
    } catch (InterruptedException exc) {
        halt(true);
    } finally {
        List<Runnable> droppedTasks = streamExecutorService.shutdownNow();

        if (CollectionUtils.isNotEmpty(droppedTasks)) {
            notifyStreamTasksDropOff(droppedTasks);
        }
    }
}

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

private void buildConsumesSection(PathOperation operation, MarkupDocBuilder docBuilder) {
    List<String> consumes = operation.getOperation().getConsumes();
    if (CollectionUtils.isNotEmpty(consumes)) {
        buildSectionTitle(CONSUMES, docBuilder);
        docBuilder.newLine();//from w  ww  .ja  v a2  s  .com
        for (String consume : consumes) {
            docBuilder.unorderedListItem(literalText(consume));
        }
        docBuilder.newLine();
    }

}

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

private void buildProducesSection(PathOperation operation, MarkupDocBuilder docBuilder) {
    List<String> produces = operation.getOperation().getProduces();
    if (CollectionUtils.isNotEmpty(produces)) {
        buildSectionTitle(PRODUCES, docBuilder);
        docBuilder.newLine();/*from  ww w . ja  v  a 2 s .  co m*/
        for (String produce : produces) {
            docBuilder.unorderedListItem(literalText(produce));
        }
        docBuilder.newLine();
    }
}

From source file:com.mirth.connect.server.api.servlets.MessageServlet.java

private MessageFilter getMessageFilter(Long minMessageId, Long maxMessageId, Long minOriginalId,
        Long maxOriginalId, Long minImportId, Long maxImportId, Calendar startDate, Calendar endDate,
        String textSearch, Boolean textSearchRegex, Set<Status> statuses, Set<Integer> includedMetaDataIds,
        Set<Integer> excludedMetaDataIds, String serverId, Set<String> rawContentSearches,
        Set<String> processedRawContentSearches, Set<String> transformedContentSearches,
        Set<String> encodedContentSearches, Set<String> sentContentSearches,
        Set<String> responseContentSearches, Set<String> responseTransformedContentSearches,
        Set<String> processedResponseContentSearches, Set<String> connectorMapContentSearches,
        Set<String> channelMapContentSearches, Set<String> sourceMapContentSearches,
        Set<String> responseMapContentSearches, Set<String> processingErrorContentSearches,
        Set<String> postprocessorErrorContentSearches, Set<String> responseErrorContentSearches,
        Set<MetaDataSearch> metaDataSearches, Set<MetaDataSearch> metaDataCaseInsensitiveSearches,
        Set<String> textSearchMetaDataColumns, Integer minSendAttempts, Integer maxSendAttempts,
        Boolean attachment, Boolean error) {
    MessageFilter filter = new MessageFilter();
    filter.setMinMessageId(minMessageId);
    filter.setMaxMessageId(maxMessageId);
    filter.setOriginalIdLower(minOriginalId);
    filter.setOriginalIdUpper(maxOriginalId);
    filter.setImportIdLower(minImportId);
    filter.setImportIdUpper(maxImportId);
    filter.setStartDate(startDate);//www .j  a  v  a 2 s  .  co  m
    filter.setEndDate(endDate);
    filter.setTextSearch(textSearch);
    filter.setTextSearchRegex(textSearchRegex);
    if (CollectionUtils.isNotEmpty(statuses)) {
        filter.setStatuses(statuses);
    }
    if (CollectionUtils.isNotEmpty(includedMetaDataIds)) {
        filter.setIncludedMetaDataIds(new ArrayList<Integer>(includedMetaDataIds));
    }
    if (CollectionUtils.isNotEmpty(excludedMetaDataIds)) {
        filter.setExcludedMetaDataIds(new ArrayList<Integer>(excludedMetaDataIds));
    }
    filter.setServerId(serverId);

    List<ContentSearchElement> contentSearchList = new ArrayList<ContentSearchElement>();
    if (CollectionUtils.isNotEmpty(rawContentSearches)) {
        contentSearchList.add(new ContentSearchElement(ContentType.RAW.getContentTypeCode(),
                new ArrayList<String>(rawContentSearches)));
    }
    if (CollectionUtils.isNotEmpty(processedRawContentSearches)) {
        contentSearchList.add(new ContentSearchElement(ContentType.PROCESSED_RAW.getContentTypeCode(),
                new ArrayList<String>(processedRawContentSearches)));
    }
    if (CollectionUtils.isNotEmpty(transformedContentSearches)) {
        contentSearchList.add(new ContentSearchElement(ContentType.TRANSFORMED.getContentTypeCode(),
                new ArrayList<String>(transformedContentSearches)));
    }
    if (CollectionUtils.isNotEmpty(encodedContentSearches)) {
        contentSearchList.add(new ContentSearchElement(ContentType.ENCODED.getContentTypeCode(),
                new ArrayList<String>(encodedContentSearches)));
    }
    if (CollectionUtils.isNotEmpty(sentContentSearches)) {
        contentSearchList.add(new ContentSearchElement(ContentType.SENT.getContentTypeCode(),
                new ArrayList<String>(sentContentSearches)));
    }
    if (CollectionUtils.isNotEmpty(responseContentSearches)) {
        contentSearchList.add(new ContentSearchElement(ContentType.RESPONSE.getContentTypeCode(),
                new ArrayList<String>(responseContentSearches)));
    }
    if (CollectionUtils.isNotEmpty(responseTransformedContentSearches)) {
        contentSearchList.add(new ContentSearchElement(ContentType.RESPONSE_TRANSFORMED.getContentTypeCode(),
                new ArrayList<String>(responseTransformedContentSearches)));
    }
    if (CollectionUtils.isNotEmpty(processedResponseContentSearches)) {
        contentSearchList.add(new ContentSearchElement(ContentType.PROCESSED_RESPONSE.getContentTypeCode(),
                new ArrayList<String>(processedResponseContentSearches)));
    }
    if (CollectionUtils.isNotEmpty(connectorMapContentSearches)) {
        contentSearchList.add(new ContentSearchElement(ContentType.CONNECTOR_MAP.getContentTypeCode(),
                new ArrayList<String>(connectorMapContentSearches)));
    }
    if (CollectionUtils.isNotEmpty(channelMapContentSearches)) {
        contentSearchList.add(new ContentSearchElement(ContentType.CHANNEL_MAP.getContentTypeCode(),
                new ArrayList<String>(channelMapContentSearches)));
    }
    if (CollectionUtils.isNotEmpty(sourceMapContentSearches)) {
        contentSearchList.add(new ContentSearchElement(ContentType.SOURCE_MAP.getContentTypeCode(),
                new ArrayList<String>(sourceMapContentSearches)));
    }
    if (CollectionUtils.isNotEmpty(responseMapContentSearches)) {
        contentSearchList.add(new ContentSearchElement(ContentType.RESPONSE_MAP.getContentTypeCode(),
                new ArrayList<String>(responseMapContentSearches)));
    }
    if (CollectionUtils.isNotEmpty(processingErrorContentSearches)) {
        contentSearchList.add(new ContentSearchElement(ContentType.PROCESSING_ERROR.getContentTypeCode(),
                new ArrayList<String>(processingErrorContentSearches)));
    }
    if (CollectionUtils.isNotEmpty(postprocessorErrorContentSearches)) {
        contentSearchList.add(new ContentSearchElement(ContentType.POSTPROCESSOR_ERROR.getContentTypeCode(),
                new ArrayList<String>(postprocessorErrorContentSearches)));
    }
    if (CollectionUtils.isNotEmpty(responseErrorContentSearches)) {
        contentSearchList.add(new ContentSearchElement(ContentType.RESPONSE_ERROR.getContentTypeCode(),
                new ArrayList<String>(responseErrorContentSearches)));
    }
    filter.setContentSearch(contentSearchList);

    List<MetaDataSearchElement> metaDataSearchList = new ArrayList<MetaDataSearchElement>();
    if (CollectionUtils.isNotEmpty(metaDataSearches)) {
        for (MetaDataSearch search : metaDataSearches) {
            metaDataSearchList.add(new MetaDataSearchElement(search.getColumnName(),
                    search.getOperator().toString(), search.getValue(), false));
        }
    }
    if (CollectionUtils.isNotEmpty(metaDataCaseInsensitiveSearches)) {
        for (MetaDataSearch search : metaDataCaseInsensitiveSearches) {
            metaDataSearchList.add(new MetaDataSearchElement(search.getColumnName(),
                    search.getOperator().toString(), search.getValue(), true));
        }
    }
    filter.setMetaDataSearch(metaDataSearchList);

    filter.setTextSearchMetaDataColumns(new ArrayList<String>(textSearchMetaDataColumns));
    filter.setSendAttemptsLower(minSendAttempts);
    filter.setSendAttemptsUpper(maxSendAttempts);
    filter.setAttachment(attachment);
    filter.setError(error);

    return filter;
}

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

private void buildTagsSection(PathOperation operation, MarkupDocBuilder docBuilder) {
    if (config.getPathsGroupedBy() == GroupBy.AS_IS) {
        List<String> tags = operation.getOperation().getTags();
        if (CollectionUtils.isNotEmpty(tags)) {
            buildSectionTitle(TAGS, docBuilder);
            Set<String> tagsSet = toSet(tags, config.getTagOrdering());
            docBuilder.unorderedList(new ArrayList<>(tagsSet));
        }//from   w  w w  . j a v  a2 s .  c o  m
    }
}

From source file:com.mirth.connect.server.MirthWebServer.java

private boolean testPackageVersion(String packageName, Version version, Class<?>[] baseClasses,
        Class<?>[] annotations) {
    packageName = getVersionedPackageName(packageName, version);
    try {/*from w  ww. j a va  2 s. c o m*/
        // Look for package-info.java first
        Class.forName(packageName + ".package-info");
        return true;
    } catch (ClassNotFoundException e) {
    }
    return CollectionUtils.isNotEmpty(getClassesInPackage(packageName, baseClasses, annotations));
}

From source file:com.mirth.connect.server.MirthWebServer.java

private String joinClasses(Set<Class<?>> classes) {
    StringBuilder builder = new StringBuilder();

    if (CollectionUtils.isNotEmpty(classes)) {
        boolean added = false;
        for (Class<?> clazz : classes) {
            if (clazz != null) {
                String name = clazz.getCanonicalName();
                if (name != null) {
                    if (added) {
                        builder.append(',');
                    }//from  w  ww  . j a  v  a  2  s.c o  m
                    builder.append(name);
                    added = true;
                }
            }
        }
    }

    return builder.toString();
}