List of usage examples for com.google.common.collect Iterables transform
@CheckReturnValue public static <F, T> Iterable<T> transform(final Iterable<F> fromIterable, final Function<? super F, ? extends T> function)
From source file:org.gradle.model.internal.core.ChainingModelProjection.java
private Iterable<String> collectDescriptions(final Function<ModelProjection, Iterable<String>> transformer) { return Iterables.concat(Iterables.transform(projections, transformer)); }
From source file:com.google.cloud.trace.v1.util.TraceBuffer.java
/** * Returns all of the trace messages in this trace buffer. * * @return an iterable containing the trace messages in this trace buffer. *///from ww w.j a va 2 s . c o m public Iterable<Trace> getTraces() { return Iterables.transform(traceMap.entrySet(), new Function<Map.Entry<TraceKey, SpanBuffer>, Trace>() { @Override public Trace apply(Map.Entry<TraceKey, SpanBuffer> entry) { Trace.Builder traceBuilder = Trace.newBuilder().setProjectId(entry.getKey().getProjectId()) .setTraceId(entry.getKey().getTraceId()); for (TraceSpan.Builder spanBuilder : entry.getValue().getSpans()) { traceBuilder.addSpans(spanBuilder); } return traceBuilder.build(); } }); }
From source file:org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.java
@Override public Set<VLANInfo> apply(HttpResponse response) { String text = returnStringIf200.apply(response); if (text == null || text.trim().equals("")) return ImmutableSet.<VLANInfo>of(); return ImmutableSet.copyOf(Iterables.transform(mapConverter.apply(text), mapToProfile)); }
From source file:com.facebook.presto.util.IterableTransformer.java
public <T> IterableTransformer<T> transformAndFlatten(Function<? super E, ? extends Iterable<T>> function) { return new IterableTransformer<>(Iterables.concat(Iterables.transform(iterable, function))); }
From source file:org.gradle.model.internal.method.WeaklyTypeReferencingMethod.java
public WeaklyTypeReferencingMethod(ModelType<T> target, ModelType<R> returnType, Method method) { this.target = target; this.returnType = returnType; this.declaringType = ModelType.of(method.getDeclaringClass()); this.name = method.getName(); paramTypes = ImmutableList.copyOf(Iterables.transform(Arrays.asList(method.getGenericParameterTypes()), new Function<Type, ModelType<?>>() { public ModelType<?> apply(Type type) { return ModelType.of(type); }//from w ww. j av a 2 s . c o m })); modifiers = method.getModifiers(); }
From source file:org.jclouds.elasticstack.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.java
@Override public Set<DriveInfo> apply(HttpResponse response) { String text = returnStringIf200.apply(response); if (text == null || text.trim().equals("")) return ImmutableSet.<DriveInfo>of(); return ImmutableSet.copyOf(Iterables.transform(mapConverter.apply(text), mapToDrive)); }
From source file:org.sonatype.nexus.orient.entity.action.BrowseEntitiesByPropertyAction.java
public Iterable<T> execute(final ODatabaseDocumentTx db, final Object value) { checkNotNull(db);//from ww w . jav a 2 s . c om checkNotNull(value); Iterable<ODocument> results = db.command(new OSQLSynchQuery<>(query)).execute(value); return Iterables.transform(results, new Function<ODocument, T>() { @Nullable @Override public T apply(@Nullable final ODocument input) { return input != null ? adapter.readEntity(input) : null; } }); }
From source file:com.twitter.aurora.scheduler.stats.ResourceCounter.java
private Iterable<ITaskConfig> getTasks(Query.Builder query) throws StorageException { return Iterables.transform(Storage.Util.consistentFetchTasks(storage, query), Tasks.SCHEDULED_TO_INFO); }
From source file:co.cask.cdap.cli.command.metadata.GetMetadataPropertiesCommand.java
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { EntityId entity = EntityId.fromString(arguments.get(ArgumentName.ENTITY.toString())); String scope = arguments.getOptional(ArgumentName.METADATA_SCOPE.toString()); Map<String, String> properties = scope == null ? client.getProperties(entity.toId()) : client.getProperties(entity.toId(), MetadataScope.valueOf(scope.toUpperCase())); Table table = Table.builder().setHeader("key", "value").setRows( Iterables.transform(properties.entrySet(), new Function<Map.Entry<String, String>, List<String>>() { @Nullable//from w w w. j a v a2 s . c o m @Override public List<String> apply(@Nullable Map.Entry<String, String> entry) { return Lists.newArrayList(entry.getKey(), entry.getValue()); } })).build(); cliConfig.getTableRenderer().render(cliConfig, output, table); }