Example usage for com.google.common.collect Collections2 filter

List of usage examples for com.google.common.collect Collections2 filter

Introduction

In this page you can find the example usage for com.google.common.collect Collections2 filter.

Prototype



@CheckReturnValue
public static <E> Collection<E> filter(Collection<E> unfiltered, Predicate<? super E> predicate) 

Source Link

Document

Returns the elements of unfiltered that satisfy a predicate.

Usage

From source file:gobblin.data.management.policy.TimeBasedSelectionPolicy.java

@Override
public Collection<TimestampedDatasetVersion> listSelectedVersions(List<TimestampedDatasetVersion> allVersions) {
    return Lists.newArrayList(Collections2.filter(allVersions, new Predicate<FileSystemDatasetVersion>() {
        @Override//from w w w  . j a  va 2s  .  c  om
        public boolean apply(FileSystemDatasetVersion version) {
            return ((TimestampedDatasetVersion) version).getDateTime().plus(lookBackPeriod).isAfterNow();
        }
    }));
}

From source file:org.tweetsmining.engines.graphsminer.graphs.gSpanExtended.ExtendedDFSCodeGenerator.java

/**
 * Removes the edges that start from the vertices that have been already visited
 * @param cert  List of possible incoming edges
 * @return      filtered edges// w w w. j av a 2s  . c  o  m
 */
@Override
public Collection<ERTriple> getEdgeVisitOrder(SortedSet<ERTriple> cert) {
    return Collections2.filter(cert, new Predicate<ERTriple>() {
        @Override
        public boolean apply(ERTriple input) {
            return (!(toAvoid.contains(input.getSource())));
        }
    });
}

From source file:com.github.fhirschmann.clozegen.lib.register.AnnotatorRegister.java

/**
 * Returns a live view of the set of Descriptions which support
 * the given {@code language}.//w ww  .java2  s .  c  o  m
 *
 * @param language the language(code)
 * @return live view of filtered descriptions
 */
public Collection<AnnotatorRegisterEntry> forLanguage(final String language) {
    return Collections2.filter(register.values(), new Predicate<AnnotatorRegisterEntry>() {
        @Override
        public boolean apply(final AnnotatorRegisterEntry input) {
            return input.getSupportedLanguages().contains(checkNotNull(language));
        }
    });
}

From source file:cc.arduino.contributions.libraries.LibrariesIndex.java

public List<ContributedLibrary> find(final String name) {
    return new LinkedList<ContributedLibrary>(
            Collections2.filter(getLibraries(), new LibraryWithNamePredicate(name)));
}

From source file:fm.last.musicbrainz.coverart.impl.CoverArtBeanDecorator.java

private CoverArtImage getImageOrNull(Predicate<CoverArtImage> filter) {
    Collection<CoverArtImage> filtered = Collections2.filter(getProxiedCoverArtImages(), filter);
    if (filtered.isEmpty()) {
        return null;
    }/*from   w w w  .j  a  v a  2s .c  o m*/
    return filtered.iterator().next();
}

From source file:com.microsoft.alm.plugin.idea.git.utils.TfGitHelper.java

public static Collection<GitRemote> getTfGitRemotes(@NotNull final GitRepository gitRepository) {
    assert gitRepository != null;
    Collection<GitRemote> gitRemotes = gitRepository.getRemotes();

    return Collections2.filter(gitRemotes, new Predicate<GitRemote>() {
        @Override/*w  w w .j a  v a  2s .com*/
        public boolean apply(final GitRemote remote) {
            return TfGitHelper.isTfGitRemote(remote);
        }
    });
}

From source file:com.anderl.hibernate.ext.IgnorableFilter.java

public void initIgnoredUrls() {

    if (ignoredUrls != null)
        return;/*from w  w w  .  j  a va 2 s .  c  o m*/
    String ignoredUrlsString = getFilterConfig().getInitParameter("ignoredUrls");
    if (StringUtils.isEmpty(ignoredUrlsString))
        return;
    this.ignoredUrls = Arrays.asList(ignoredUrlsString.split(","));
    this.ignoredUrls = Lists.newArrayList(Collections2.filter(ignoredUrls, new Predicate<String>() {
        @Override
        public boolean apply(String ignoredUrl) {
            return !StringUtils.isEmpty(ignoredUrl);
        }
    }));
}

From source file:me.taylorkelly.mywarp.warp.MemoryWarpManager.java

@Override
public Collection<Warp> filter(Predicate<Warp> predicate) {
    return Collections2.filter(warpMap.values(), predicate);
}

From source file:org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase.java

/**
 * Constructor.//from   w  ww .  jav a2  s  . co m
 *
 * @param ctx
 *            context of statement.
 */
protected EffectiveStatementBase(final StmtContext<A, D, ?> ctx) {
    final Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements = ctx.effectiveSubstatements();
    final Collection<StatementContextBase<?, ?, ?>> substatementsInit = new ArrayList<>();

    final Collection<StatementContextBase<?, ?, ?>> supportedDeclaredSubStmts = Collections2
            .filter(ctx.declaredSubstatements(), StmtContextUtils::areFeaturesSupported);
    for (final StatementContextBase<?, ?, ?> declaredSubstatement : supportedDeclaredSubStmts) {
        if (declaredSubstatement.getPublicDefinition().equals(YangStmtMapping.USES)) {
            substatementsInit.add(declaredSubstatement);
            substatementsInit.addAll(declaredSubstatement.getEffectOfStatement());
            ((StatementContextBase<?, ?, ?>) ctx)
                    .removeStatementsFromEffectiveSubstatements(declaredSubstatement.getEffectOfStatement());
        } else {
            substatementsInit.add(declaredSubstatement);
        }
    }
    substatementsInit.addAll(effectiveSubstatements);

    this.substatements = ImmutableList.copyOf(initSubstatements(substatementsInit));
}

From source file:co.cask.cdap.notifications.feeds.service.InMemoryNotificationFeedStore.java

@Override
public synchronized List<Id.NotificationFeed> listNotificationFeeds(final Id.Namespace namespace) {
    Collection<Id.NotificationFeed> filter = Collections2.filter(feeds.values(),
            new Predicate<Id.NotificationFeed>() {
                @Override/*from w  w w .j a v  a  2  s  . c  o  m*/
                public boolean apply(@Nullable Id.NotificationFeed input) {
                    if (input != null && input.getNamespaceId().equals(namespace.getId())) {
                        return true;
                    }
                    return false;
                }
            });
    return ImmutableList.copyOf(filter);
}