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

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

Introduction

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

Prototype

public static <F, T> Iterator<T> transform(final Iterator<F> fromIterator,
        final Function<? super F, ? extends T> function) 

Source Link

Document

Returns an iterator that applies function to each element of fromIterator .

Usage

From source file:com.nirima.jenkins.repo.project.ProjectsElement.java

public Collection<ProjectElement> getChildren() {

    List<ProjectElement> elements = Lists.newArrayList(Iterators.transform(
            Jenkins.getInstance().getAllItems(BuildableItemWithBuildWrappers.class).iterator(),
            new Function<BuildableItemWithBuildWrappers, ProjectElement>() {
                public ProjectElement apply(BuildableItemWithBuildWrappers from) {
                    return new ProjectElement(ProjectsElement.this, from);
                }/*from w  w w.  j a va 2s  . co  m*/
            }));

    return elements;
}

From source file:de.unijena.bioinf.FragmentationTreeConstruction.model.DecompositionList.java

public Collection<MolecularFormula> getFormulas() {
    return new AbstractCollection<MolecularFormula>() {
        @Override/*from   www. j  ava 2  s . c o m*/
        public Iterator<MolecularFormula> iterator() {
            return Iterators.transform(decompositions.iterator(),
                    new Function<ScoredMolecularFormula, MolecularFormula>() {
                        @Override
                        public MolecularFormula apply(ScoredMolecularFormula input) {
                            return input.getFormula();
                        }
                    });
        }

        @Override
        public int size() {
            return decompositions.size();
        }
    };
}

From source file:org.apache.gobblin.util.request_allocation.StringRequestor.java

@Override
public Iterator<StringRequest> getRequests(Comparator<StringRequest> prioritizer) throws IOException {
    List<StringRequest> requests = Lists
            .newArrayList(Iterators.transform(this.strings.iterator(), new Function<String, StringRequest>() {
                @Override//from w w  w .j a v  a  2s.  c o m
                public StringRequest apply(String input) {
                    return new StringRequest(StringRequestor.this, input);
                }
            }));
    Collections.sort(requests, prioritizer);
    return requests.iterator();
}

From source file:org.grouplens.lenskit.collections.CopyingFastCollection.java

@Override
public Iterator<E> iterator() {
    return Iterators.transform(fastIterator(), copyFunction);
}

From source file:com.eightkdata.mongowp.bson.impl.MapBasedBsonDocument.java

@Override
public UnmodifiableIterator<Entry<?>> iterator() {
    return Iterators.unmodifiableIterator(
            Iterators.transform(map.entrySet().iterator(), AbstractBsonDocument.FromEntryMap.INSTANCE));
}

From source file:org.polymap.model2.engine.ManyAssociationImpl.java

@Override
public Iterator<T> iterator() {
    return Iterators.transform(storeProp.iterator(), new Function<Object, T>() {

        UnitOfWork uow = context.getUnitOfWork();

        Class<? extends Entity> entityType = info().getType();

        @Override/*from   w w w. j  a v  a 2 s . c o  m*/
        public T apply(Object id) {
            return (T) uow.entity(entityType, id);
        }
    });
}

From source file:eu.interedition.collatex.neo4j.Neo4jVariantGraphTransposition.java

@Override
public Iterator<VariantGraph.Vertex> iterator() {
    return Iterators.transform(node.getRelationships(Neo4jGraphRelationships.TRANSPOSITION).iterator(),
            new Function<Relationship, VariantGraph.Vertex>() {
                @Override//from   w w  w.j a  va2s.  c  o m
                public VariantGraph.Vertex apply(@Nullable Relationship relationship) {
                    return graph.vertexWrapper.apply(relationship.getEndNode());
                }
            });
}

From source file:eu.stratosphere.sopremo.type.PullingStreamNode.java

@SuppressWarnings("unchecked")
public void setSource(final IStreamNode<?> node) {
    this.source = (Iterator<IJsonNode>) node.iterator();
    this.iterator = Iterators.transform(this.source, new Function<IJsonNode, T>() {
        @Override/* w w w .  j  a  v  a 2 s. co  m*/
        public T apply(final IJsonNode inputNode) {
            return (T) PullingStreamNode.this.expression.evaluate(inputNode);
        }
    });
}

From source file:org.apache.accumulo.core.util.shell.commands.NamespacesCommand.java

@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState)
        throws AccumuloException, AccumuloSecurityException, IOException {
    Map<String, String> namespaces = new TreeMap<String, String>(
            shellState.getConnector().namespaceOperations().namespaceIdMap());

    Iterator<String> it = Iterators.transform(namespaces.entrySet().iterator(),
            new Function<Entry<String, String>, String>() {
                @Override//from   w w  w  .j a  v  a  2 s  .c  o  m
                public String apply(Map.Entry<String, String> entry) {
                    String name = entry.getKey();
                    if (Namespaces.DEFAULT_NAMESPACE.equals(name))
                        name = DEFAULT_NAMESPACE_DISPLAY_NAME;
                    String id = entry.getValue();
                    if (cl.hasOption(namespaceIdOption.getOpt()))
                        return String.format(TablesCommand.NAME_AND_ID_FORMAT, name, id);
                    else
                        return name;
                };
            });

    shellState.printLines(it, !cl.hasOption(disablePaginationOpt.getOpt()));
    return 0;
}

From source file:org.geoserver.data.versioning.decorator.QueryFeatureCollector.java

@Override
public Iterator<Feature> iterator() {

    GeoGIT ggit = new GeoGIT(repository);
    VersionQuery versionQuery = new VersionQuery(ggit, featureType.getName());
    Iterator<Ref> featureRefs;
    try {//from ww  w  .j av a2s .  c o  m
        featureRefs = versionQuery.getByQuery(query);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    Iterator<Feature> features = Iterators.transform(featureRefs, new RefToFeature(repository, featureType));

    return features;
}