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

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

Introduction

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

Prototype

@CheckReturnValue
public static <F, T> Iterable<T> transform(final Iterable<F> fromIterable,
        final Function<? super F, ? extends T> function) 

Source Link

Document

Returns an iterable that applies function to each element of fromIterable .

Usage

From source file:com.google.devtools.build.xcode.actoolzip.ActoolZip.java

@Override
public Iterable<String> subCommand(Arguments args, String outputDirectory) {
    return new ImmutableList.Builder<String>().add(args.subtoolCmd()).add("--compile").add(outputDirectory)
            // actool munges paths in some way which doesn't work if one of the directories in the path
            // is a symlink.
            .addAll(Iterables.transform(args.subtoolExtraArgs(), Wrappers.CANONICALIZE_IF_PATH)).build();
}

From source file:shaded.org.openqa.selenium.remote.server.handler.html5.ExecuteSQL.java

@Override
public void setJsonParameters(Map<String, Object> allParameters) throws Exception {
    dbName = (String) allParameters.get("dbName");
    query = (String) allParameters.get("query");
    List<?> params = (List<?>) allParameters.get("args");
    args = Lists.newArrayList(Iterables.transform(params, new ArgumentConverter(getKnownElements())));
}

From source file:de.cosmocode.palava.ipc.conversation.CompletionFailedException.java

@Override
public String getMessage() {
    return JOINER.join(Iterables.transform(errors.keySet(), Throwables.getMessage()));
}

From source file:com.metamx.common.guava.FunctionalIterable.java

public <RetType> FunctionalIterable<RetType> transform(Function<T, RetType> fn) {
    return new FunctionalIterable<>(Iterables.transform(delegate, fn));
}

From source file:org.apache.mahout.cf.taste.example.kddcup.track1.svd.KDDCupFactorizablePreferences.java

@Override
public Iterable<Preference> getPreferences() {
    Iterable<Iterable<Preference>> prefIterators = Iterables.transform(new DataFileIterable(dataFile),
            new Function<Pair<PreferenceArray, long[]>, Iterable<Preference>>() {
                @Override/* w w w.ja va2 s . co m*/
                public Iterable<Preference> apply(Pair<PreferenceArray, long[]> from) {
                    return from.getFirst();
                }
            });
    return Iterables.concat(prefIterators);
}

From source file:com.google.gxp.compiler.cpp.CppHeaderCodeGenerator.java

public CppHeaderCodeGenerator(MessageExtractedTree tree, Set<Callable> requirements) {
    super(tree);//from  www  . j  av  a  2s. c om

    // unlike java, you have to include the header file for anything you depend on,
    // you can't just fully qualify the class name, so build up a list of extra includes
    this.extraIncludess = ImmutableSet
            .copyOf(Iterables.transform(requirements, new Function<Callable, TemplateName>() {
                public TemplateName apply(Callable requirement) {
                    return requirement.getName();
                }
            }));
}

From source file:com.synflow.cx.internal.compiler.ActorBuilder.java

public ActorBuilder(IInstantiator instantiator, Typer typer, Actor actor) {
    super(instantiator, typer, actor);

    existingSet = ImmutableSet.copyOf(/*from   w w  w .  j  av a2 s  . c om*/
            Iterables.transform(Iterables.concat(actor.getInputs(), actor.getOutputs(), actor.getVariables()),
                    new Function<Var, String>() {
                        @Override
                        public String apply(Var var) {
                            return var.getName();
                        }
                    }));
}

From source file:gobblin.data.management.convertion.hive.TableLevelWatermarker.java

public TableLevelWatermarker(SourceState state) {
    this.tableWatermarks = Maps.newHashMap();
    SourceState sourceState = state;/*ww w.  j av  a  2 s.c o  m*/

    for (Map.Entry<String, Iterable<WorkUnitState>> datasetWorkUnitStates : sourceState
            .getPreviousWorkUnitStatesByDatasetUrns().entrySet()) {

        LongWatermark tableWatermark = Collections.min(Lists.newArrayList(Iterables
                .transform(datasetWorkUnitStates.getValue(), new Function<WorkUnitState, LongWatermark>() {
                    @Override
                    public LongWatermark apply(WorkUnitState w) {
                        return GSON.fromJson(w.getActualHighWatermark(), LongWatermark.class);
                    }
                })));

        this.tableWatermarks.put(datasetWorkUnitStates.getKey(), tableWatermark);

    }

}

From source file:org.jclouds.json.internal.ParseObjectFromElement.java

public Object apply(JsonElement input) {
    Object value = null;/*from   ww w.ja v a  2 s  . c  om*/
    if (input == null || input.isJsonNull()) {
        value = null;
    } else if (input.isJsonPrimitive()) {
        JsonPrimitive primitive = input.getAsJsonPrimitive();
        if (primitive.isNumber()) {
            value = primitive.getAsNumber();
        } else if (primitive.isBoolean()) {
            value = primitive.getAsBoolean();
        } else {
            value = primitive.getAsString();
        }
    } else if (input.isJsonArray()) {
        value = Lists.newArrayList(Iterables.transform(input.getAsJsonArray(), this));
    } else if (input.isJsonObject()) {
        value = Maps.<String, Object>newLinkedHashMap(
                Maps.transformValues(JsonObjectAsMap.INSTANCE.apply(input.getAsJsonObject()), this));
    }
    return value;
}

From source file:org.incode.module.commchannel.dom.impl.channel.CommunicationChannelRepository.java

@Programmatic
public SortedSet<CommunicationChannel> findByOwner(final Object owner) {
    final List<CommunicationChannelOwnerLink> links = linkRepository.findByOwner(owner);
    return Sets.newTreeSet(
            Iterables.transform(links, CommunicationChannelOwnerLink.Functions.communicationChannel()));
}