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:org.fcrepo.kernel.api.utils.iterators.RdfStream.java

/**
 * Constructor that begins the stream with proffered statements.
 *
 * @param statements the statements/*from www  . ja  v a  2 s.c o  m*/
 * @param <T> extends {@link Statement}
 */
@SafeVarargs
public <T extends Statement> RdfStream(final T... statements) {
    this(Iterators.transform(Iterators.forArray(statements), x -> x.asTriple()));
}

From source file:org.apache.fluo.core.log.TracingTransaction.java

private String encRC(Map<Bytes, Map<Column, Bytes>> ret) {
    return Iterators.toString(Iterators.transform(ret.entrySet().iterator(),
            new Function<Entry<Bytes, Map<Column, Bytes>>, String>() {
                @Override/*  w w w .  jav a2  s. co m*/
                public String apply(Entry<Bytes, Map<Column, Bytes>> e) {
                    return enc(e.getKey()) + "=" + encC(e.getValue());
                }
            }));
}

From source file:org.apache.giraph.block_app.framework.block.FilteringBlock.java

@Override
public Iterator<AbstractPiece> iterator() {
    return Iterators.transform(block.iterator(), new Function<AbstractPiece, AbstractPiece>() {
        @Override//from  ww  w.j  ava2 s.c  om
        public AbstractPiece apply(AbstractPiece input) {
            return new FilteringPiece<>(toCallSend, toCallReceive, input);
        }
    });
}

From source file:com.google.devtools.build.lib.rules.android.AarGeneratorBuilder.java

private static String convertRoots(ResourceContainer container, ResourceType resourceType) {
    return Joiner.on("#").join(
            Iterators.transform(container.getRoots(resourceType).iterator(), Functions.toStringFunction()));
}

From source file:org.obm.provisioning.utils.SerializationUtils.java

private static Collection<String> getCurrentTokenTextValues(JsonNode value) {
    Iterator<String> it = Iterators.transform(value.getElements(), new Function<JsonNode, String>() {
        @Override/* www .ja  va  2 s  .c o m*/
        public String apply(JsonNode input) {
            return input.asText();
        }
    });

    Collection<String> textValues = Lists.newArrayList();
    Iterators.addAll(textValues, it);

    return textValues;
}

From source file:org.sosy_lab.cpachecker.core.reachedset.UnmodifiableReachedSetView.java

@Override
public Iterator<AbstractState> iterator() {
    return Iterators.transform(underlying.iterator(), mapStateFunction);
}

From source file:io.crate.metadata.RoutineInfos.java

private Iterator<RoutineInfo> builtInTokenizers() {
    return Iterators.transform(ftResolver.getBuiltInTokenizers().iterator(),
            new Function<String, RoutineInfo>() {
                @Nullable/*ww w.  j av a2  s.c  om*/
                @Override
                public RoutineInfo apply(@Nullable String input) {
                    return new RoutineInfo(input, RoutineType.TOKENIZER.getName());
                }
            });
}

From source file:org.apache.jackrabbit.oak.security.user.AbstractGroupPrincipal.java

@Override
public Enumeration<? extends Principal> members() {
    final Iterator<Authorizable> members;
    try {// w ww .j  a  va2 s . c  om
        members = getMembers();
    } catch (RepositoryException e) {
        // should not occur.
        String msg = "Unable to retrieve Group members: " + e.getMessage();
        log.error(msg);
        throw new IllegalStateException(msg, e);
    }

    Iterator<Principal> principals = Iterators.transform(members, new Function<Authorizable, Principal>() {
        @Override
        public Principal apply(Authorizable authorizable) {
            if (authorizable == null) {
                return null;
            }
            try {
                return authorizable.getPrincipal();
            } catch (RepositoryException e) {
                String msg = "Internal error while retrieving principal: " + e.getMessage();
                log.error(msg);
                throw new IllegalStateException(msg, e);
            }
        }
    });
    return Iterators.asEnumeration(Iterators.filter(principals, Predicates.<Object>notNull()));
}

From source file:org.janusgraph.graphdb.tinkerpop.optimize.JanusGraphPropertiesStep.java

private Iterator<E> convertIterator(Iterable<? extends JanusGraphProperty> iterable) {
    if (getReturnType().forProperties())
        return (Iterator<E>) iterable.iterator();
    assert getReturnType().forValues();
    return (Iterator<E>) Iterators.transform(iterable.iterator(), p -> ((JanusGraphProperty) p).value());
}

From source file:de.zib.gndms.c3resource.C3ResourceReader.java

public Iterator<Site> readXmlSites(final @NotNull String requiredPrefixParam, final @NotNull InputStream in) {
    return Iterators
            .concat(Iterators.transform(validResources(in), new Function<C3GridResource, Iterator<Site>>() {
                public Iterator<Site> apply(@Nullable final C3GridResource resourceParam) {
                    return Iterators.filter(resourceParam.getSite().iterator(), new Predicate<Site>() {
                        public boolean apply(@Nullable final Site siteParam) {
                            final String id = siteParam.getId();
                            return id != null && id.startsWith(requiredPrefixParam);

                        }/*from  w  w w . j  av  a2 s  .  c om*/
                    });
                }
            }));
}