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:nl.socrates.dom.utils.StringUtils.java

public static String enumDeTitle(final String string) {
    if (string == null) {
        return null;
    }/*from   w w w  .  j  av  a 2 s.  c o m*/
    return Joiner.on("_").join(Iterables.transform(Splitter.on(" ").split(string), UPPER_CASE));
}

From source file:de.flapdoodle.guava.Flatter.java

public static <A, P, T> Function<? super Flat<A, P>, Iterable<? extends Flat<Flat<A, P>, T>>> flatted(
        final Function<? super P, ? extends Iterable<? extends T>> sub) {
    return new Function<Flat<A, P>, Iterable<? extends Flat<Flat<A, P>, T>>>() {

        @Override/*from ww w .j a va  2s.  com*/
        public Iterable<? extends Flat<Flat<A, P>, T>> apply(final Flat<A, P> parent) {
            return Iterables.transform(sub.apply(parent.value()), new Function<T, Flat<Flat<A, P>, T>>() {
                public Flat<Flat<A, P>, T> apply(T value) {
                    return new Flat<Flat<A, P>, T>(parent, value);
                };
            });
        }

    };
}

From source file:org.apache.phoenix.pig.util.ColumnInfoToStringEncoderDecoder.java

public static List<ColumnInfo> decode(final String columnInfoStr) {
    Preconditions.checkNotNull(columnInfoStr);
    List<ColumnInfo> columnInfos = Lists.newArrayList(
            Iterables.transform(Splitter.on(COLUMN_INFO_DELIMITER).omitEmptyStrings().split(columnInfoStr),
                    new Function<String, ColumnInfo>() {
                        @Override
                        public ColumnInfo apply(String colInfo) {
                            if (colInfo.isEmpty()) {
                                return null;
                            }//w ww .  j a v  a2s. c om
                            return ColumnInfo.fromString(colInfo);
                        }
                    }));
    return columnInfos;

}

From source file:org.trancecode.xml.saxon.SaxonNamespaces.java

public static Iterable<Entry<String, String>> namespaceSequence(final XdmNode node) {
    final InscopeNamespaceResolver namespaceResolver = new InscopeNamespaceResolver(node.getUnderlyingNode());
    return Iterables.transform(prefixes(node),
            prefix -> Maps.immutableEntry(prefix, namespaceResolver.getURIForPrefix(prefix, true)));
}

From source file:es.usc.citius.hipster.thirdparty.graphs.blueprints.BlueprintsHipsterGraphAdapter.java

protected static Iterable<GraphEdge<Vertex, Edge>> convertEdges(Iterable<Edge> edges) {
    return Iterables.transform(edges, new Function<Edge, GraphEdge<Vertex, Edge>>() {
        @Override//from  ww w  . j  ava2  s .  co  m
        public GraphEdge<Vertex, Edge> apply(@Nullable Edge edge) {
            return new GraphEdge<Vertex, Edge>(edge.getVertex(Direction.IN), edge.getVertex(Direction.OUT),
                    edge);
        }
    });
}

From source file:com.google.devtools.build.lib.skyframe.TargetCompletionValue.java

public static Iterable<SkyKey> keys(Collection<ConfiguredTarget> targets, final TopLevelArtifactContext ctx) {
    return Iterables.transform(targets, new Function<ConfiguredTarget, SkyKey>() {
        @Override/*from w w w . java2 s  .c om*/
        public SkyKey apply(ConfiguredTarget ct) {
            return SkyKey.create(SkyFunctions.TARGET_COMPLETION,
                    TargetCompletionKey.create(LabelAndConfiguration.of(ct), ctx));
        }
    });
}

From source file:com.google.devtools.build.lib.analysis.platform.PlatformProviderUtils.java

/** Retrieves and casts {@link ConstraintSettingInfo} providers from the given targets. */
public static Iterable<ConstraintSettingInfo> constraintSettings(
        Iterable<? extends SkylarkProviderCollection> targets) {
    return Iterables.transform(targets, PlatformProviderUtils::constraintSetting);
}

From source file:com.facebook.buck.jvm.scala.ScalacToJarStepFactory.java

public static ImmutableList<String> collectScalacArguments(ScalaBuckConfig config, BuildRuleResolver resolver,
        ImmutableList<String> extraArguments) {

    return ImmutableList.<String>builder().addAll(config.getCompilerFlags()).addAll(extraArguments)
            .addAll(Iterables.transform(resolver.getAllRules(config.getCompilerPlugins()),
                    input -> "-Xplugin:" + input.getPathToOutput()))
            .build();/*from  ww  w  .ja  va  2s .c  o m*/
}

From source file:org.apache.druid.query.dimension.DefaultDimensionSpec.java

public static List<DimensionSpec> toSpec(Iterable<String> dimensionNames) {
    return Lists.newArrayList(Iterables.transform(dimensionNames, new Function<String, DimensionSpec>() {
        @Override/*from   w  w w  .  j  a  va  2 s  .c  o  m*/
        public DimensionSpec apply(String input) {
            return new DefaultDimensionSpec(input, input);
        }
    }));
}

From source file:org.gradle.internal.component.IncompatibleConfigurationSelectionException.java

private static String generateMessage(AttributeContainer fromConfigurationAttributes,
        AttributesSchema consumerSchema, ComponentResolveMetadata targetComponent, String targetConfiguration) {
    Set<String> requestedAttributes = Sets
            .newTreeSet(Iterables.transform(fromConfigurationAttributes.keySet(), ATTRIBUTE_NAME));
    TreeFormatter formatter = new TreeFormatter();
    formatter.node("Configuration '" + targetConfiguration + "' in "
            + targetComponent.getComponentId().getDisplayName() + " does not match the consumer attributes");
    formatConfiguration(formatter, fromConfigurationAttributes, consumerSchema,
            Collections.singletonList(targetComponent.getConfiguration(targetConfiguration)),
            requestedAttributes, targetConfiguration);
    return formatter.toString();
}