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

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

Introduction

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

Prototype

@SuppressWarnings("unchecked") 
@GwtIncompatible("Class.isInstance")
@CheckReturnValue
public static <T> UnmodifiableIterator<T> filter(Iterator<?> unfiltered, Class<T> desiredType) 

Source Link

Document

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

Usage

From source file:to.lean.tools.gmail.importer.local.thunderbird.ThunderbirdMailStorage.java

@Override
protected Iterator<JavaxMailFolder> filterFolders(Iterator<JavaxMailFolder> iterator) {
    return Iterators.filter(iterator, folder -> !folder.getName().contains("@"));
}

From source file:org.eclipse.sirius.business.internal.session.SessionTransientAttachment.java

/**
 * This utility method look through every adapter associated with the given
 * instance to retrieve, if it is there, any instance of
 * {@link SessionTransientAttachment}./*  w  ww  .  jav a2s.  co m*/
 * 
 * @param eObj
 *            the instance to inspect.
 * @return an optional SessionTransientAttachment.
 */
public static Option<SessionTransientAttachment> getSessionTransientAttachement(Notifier eObj) {
    Iterator<SessionTransientAttachment> it = Iterators
            .filter(Sets.newLinkedHashSet(eObj.eAdapters()).iterator(), SessionTransientAttachment.class);
    if (it.hasNext()) {
        return Options.newSome(it.next());
    }
    return Options.newNone();
}

From source file:nz.ac.massey.cs.guery.AbstractGraphAdapter.java

@Override
public Iterator<E> getOutEdges(V vertex, Predicate<? super E> filter) {
    return Iterators.filter(getOutEdges(vertex), filter);
}

From source file:com.bitranger.parknshop.common.recommend.collections.FilteringFastIterable.java

@Override
public Iterator<E> iterator() {
    return limit(Iterators.filter(delegate.iterator(), predicate));
}

From source file:org.eclipse.sirius.tree.business.api.query.TreeDescriptionQuery.java

/**
 * Returns all the descendant mappings of the TreeDescription.
 * // w  w  w .ja  va 2 s .c  om
 * @return all the descendant mappings of the TreeDescription
 */
public Iterable<? extends TreeItemMapping> getAllDescendantMappings() {
    if (description != null) {
        return Lists.newArrayList(Iterators.filter(description.eAllContents(), TreeItemMapping.class));
    } else {
        return Collections.emptyList();
    }
}

From source file:jflowmap.ui.ClusterNodesTableModel.java

public void setVisualNodes(List<VisualNode> nodes) {
    if (nodes == null) {
        this.visualNodes = null;
        this.clusterIcons = null;
    } else {/*from w w  w . j av a2s. c om*/
        this.visualNodes = Lists.newArrayList(Iterators.filter(nodes.iterator(), new Predicate<VisualNode>() {
            public boolean apply(VisualNode node) {
                return node.getClusterTag() != null;
            }
        }));
        Collections.sort(visualNodes, VisualNode.LABEL_COMPARATOR);
        fireTableDataChanged();
        //fireTableChanged();
        fireTableStructureChanged();
        initClusterIcons();
    }
}

From source file:org.geogit.rest.repository.GeogitResourceUtils.java

public static List<DataStoreInfo> findGeogitStores(Request request) {
    List<DataStoreInfo> geogitStores;

    Catalog catalog = getCatalog(request);
    org.opengis.filter.Filter filter = Predicates.equal("type", GeoGitDataStoreFactory.DISPLAY_NAME);
    CloseableIterator<DataStoreInfo> stores = catalog.list(DataStoreInfo.class, filter);
    try {/*from   w  ww.ja  va2s  .c  o m*/
        Predicate<DataStoreInfo> enabled = new Predicate<DataStoreInfo>() {
            @Override
            public boolean apply(@Nullable DataStoreInfo input) {
                return input.isEnabled();
            }
        };
        geogitStores = ImmutableList.copyOf(Iterators.filter(stores, enabled));
    } finally {
        stores.close();
    }

    return geogitStores;
}

From source file:com.eviware.loadui.impl.reporting.statistics.ChartLegendDataSource.java

public ChartLegendDataSource(LineChartView chartView) {
    super(true);//from  www  .java 2  s  . com

    this.chartView = chartView;
    iterator = Iterators.filter(chartView.getSegments().iterator(), LineSegment.class);
}

From source file:org.geogit.api.data.FindFeatureTypeTrees.java

@Override
public List<NodeRef> call() {
    Preconditions.checkNotNull(refSpec, "refSpec was not provided");
    Iterator<NodeRef> allTrees;
    try {/* w  w  w  . jav  a  2s.  c o m*/
        allTrees = commandLocator.command(LsTreeOp.class).setReference(refSpec)
                .setStrategy(LsTreeOp.Strategy.DEPTHFIRST_ONLY_TREES).call();
    } catch (IllegalArgumentException noWorkHead) {
        return ImmutableList.of();
    }
    Iterator<NodeRef> typeTrees = Iterators.filter(allTrees, new Predicate<NodeRef>() {
        @Override
        public boolean apply(NodeRef input) {
            ObjectId metadataId = input.getMetadataId();
            return !metadataId.isNull();
        }
    });

    return ImmutableList.copyOf(typeTrees);
}

From source file:nz.ac.massey.cs.guery.AbstractGraphAdapter.java

@Override
public Iterator<V> getVertices(Predicate<? super V> filter) {
    return Iterators.filter(getVertices(), filter);
}