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

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

Introduction

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

Prototype

@GwtIncompatible("Class.isInstance")
@CheckReturnValue
public static <T> Iterable<T> filter(final Iterable<?> unfiltered, final Class<T> desiredType) 

Source Link

Document

Returns all elements in unfiltered that are of the type desiredType .

Usage

From source file:org.eclipse.xtext.scoping.impl.LoadOnDemandResourceDescriptions.java

@Override
public Iterable<IResourceDescription> getAllResourceDescriptions() {
    return Iterables.filter(Iterables.transform(validUris, new Function<URI, IResourceDescription>() {
        @Override/*from   w  ww  .  j a  v a  2s . c  o m*/
        public IResourceDescription apply(URI from) {
            return getResourceDescription(from);
        }
    }), Predicates.notNull());
}

From source file:uk.ac.stfc.isis.ibex.configserver.internal.ComponentFilteredConfiguration.java

/**
 * Takes a collection of blocks and filters out the ones that are part of a
 * component.//from  w w w .  j  av  a2  s. co m
 * 
 * @param blocks
 *            The blocks
 * @return The filtered collection of blocks
 */
public static Collection<Block> filterBlocks(Collection<Block> blocks) {
    return Lists.newArrayList(Iterables.filter(blocks, new Predicate<Block>() {
        @Override
        public boolean apply(Block block) {
            return !block.hasComponent();
        }
    }));
}

From source file:cosmos.results.CloseableIterable.java

public static <T> CloseableIterable<T> filterAndTransform(ScannerBase scanner,
        Predicate<Entry<Key, Value>> filter, Function<Entry<Key, Value>, T> func, Tracer t, String desc,
        Stopwatch sw) {//from  w  w w.  j  a  v  a  2  s.c  o  m
    return new CloseableIterable<T>(scanner, Iterables.transform(Iterables.filter(scanner, filter), func), t,
            desc, sw);
}

From source file:playground.michalm.util.gis.PolygonBasedFilter.java

public static Iterable<? extends Link> filterLinksInsidePolygon(Iterable<? extends Link> links,
        Geometry polygonGeometry, boolean includeBorderLinks) {
    return Iterables.filter(links, createLinkInsidePolygonPredicate(polygonGeometry, includeBorderLinks));
}

From source file:org.apache.abdera2.common.selector.AbstractSelector.java

public Iterable<X> filter(Iterable<X> items) {
    if (items == null)
        return ImmutableSet.<X>of();
    return Iterables.filter(items, this);
}

From source file:org.eclipse.sirius.diagram.ui.tools.internal.figure.locator.FeedbackDBorderItemLocator.java

@Override
protected List<IFigure> getBrotherFigures(IFigure targetBorderItem) {
    IFigure parentFigure = getParentFigure();
    if (parentFigure instanceof BorderedNodeFigure) {
        parentFigure = ((BorderedNodeFigure) parentFigure).getBorderItemContainer();
    }//www  .  j  av a  2s.  co m
    @SuppressWarnings("unchecked")
    Iterable<IFigure> brotherFigures = Iterables.filter(parentFigure.getChildren(), Predicates
            .and(Predicates.instanceOf(IFigure.class), Predicates.not(Predicates.equalTo(targetBorderItem))));
    return Lists.newArrayList(brotherFigures);
}

From source file:org.eclipse.sirius.table.business.internal.metamodel.spec.DTableSpec.java

/**
 * {@inheritDoc}/*www  .j a va2  s  .c o  m*/
 */
@Override
public void activate(DTableElementSynchronizer sync) {
    for (DTableElementUpdater updater : Iterables.filter(AllContents.of(this), DTableElementUpdater.class)) {
        updater.activate(sync);
    }
}

From source file:org.vclipse.refactoring.utils.EntrySearch.java

public EObject findEntry(EObject object, Iterable<EObject> entries) {
    Iterable<? extends EObject> typedFilter = Iterables.filter(entries, object.getClass());
    for (EObject entry : typedFilter) {
        boolean similar = similar(entry, object);
        if (similar) {
            return entry;
        }/*w  w w. j  av a 2s.  c  o m*/
    }
    return null;
}

From source file:org.eclipse.ocl.pivot.internal.library.executor.DomainProperties.java

public @NonNull Iterable<? extends Property> getAllProperties(final @Nullable FeatureFilter featureFilter) {
    @NonNull//from ww w.java 2  s. com
    Collection<Property> values = name2property.values();
    if (featureFilter == null) {
        return values;
    }
    @SuppressWarnings("null")
    @NonNull
    Iterable<Property> subItOps = Iterables.filter(values, new Predicate<Property>() {
        @Override
        public boolean apply(Property domainProperty) {
            return (domainProperty != null) && featureFilter.accept(domainProperty);
        }
    });
    return subItOps;
}

From source file:nz.co.testamation.common.util.PrefixMapNamespaceContext.java

public Iterator<String> getPrefixes(final String namespaceURI) {
    return Iterables.transform(
            Iterables.filter(prefixNamespaceMap.entrySet(), new Predicate<Map.Entry<String, String>>() {
                @Override/*  w ww.  ja v a  2  s. c  o  m*/
                public boolean apply(Map.Entry<String, String> entry) {
                    return namespaceURI.equals(entry.getValue());
                }
            }), new Function<Map.Entry<String, String>, String>() {
                @Override
                public String apply(Map.Entry<String, String> entry) {
                    return entry.getKey();
                }
            }).iterator();

}