List of usage examples for com.google.common.collect Lists transform
@CheckReturnValue public static <F, T> List<T> transform(List<F> fromList, Function<? super F, ? extends T> function)
From source file:see.functions.functional.Transform.java
/** * Choose appropriate transformation based on runtime type of collection * @param items collection to transform//from ww w .ja v a 2 s . c om * @param transformation item transformation * @return lazy transformed collection */ private Iterable<?> transform(Iterable<?> items, Function<Object, Object> transformation) { if (items instanceof List<?>) { return Lists.transform((List<?>) items, transformation); } else if (items instanceof Collection<?>) { return Collections2.transform((Collection<?>) items, transformation); } else { return Iterables.transform(items, transformation); } }
From source file:de.brands4friends.daleq.core.RowBuilder.java
private List<FieldData> mapFieldsToContainers(final Context context, final TableType tableType, final Map<FieldType, FieldHolder> typeToHolder) { return Lists.transform(tableType.getFields(), new Function<FieldType, FieldData>() { @Override//from ww w.j a v a 2s.c om public FieldData apply(@Nullable final FieldType fieldType) { final FieldHolder actualField = typeToHolder.get(fieldType); if (actualField == null) { return convertDefaultField(fieldType, context); } return convertProvidedField(fieldType, actualField, context); } }); }
From source file:org.apache.provisionr.core.activities.InstallRepositories.java
private List<Map<String, String>> repositoriesAsListOfMaps(Software software) { return Lists.transform(software.getRepositories(), new Function<Repository, Map<String, String>>() { @Override/*from w ww . j a va2 s. c o m*/ public Map<String, String> apply(Repository repository) { ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String>builder() .put("name", repository.getName()) .put("content", Joiner.on("\\n").join(repository.getEntries())); if (repository.getKey().isPresent()) { builder.put("key", repository.getKey().get().replace("\n", "\\n")); } return builder.build(); } }); }
From source file:org.brooth.jeta.apt.MetacodeUtils.java
public static List<String> extractClassesNames(Runnable invoke) { try {/*from ww w . java 2 s.c o m*/ invoke.run(); throw new IllegalArgumentException("invoke doesn't throw MirroredTypesException"); } catch (MirroredTypesException e) { return Lists.transform(e.getTypeMirrors(), new Function<TypeMirror, String>() { public String apply(TypeMirror input) { return input.toString(); } }); } }
From source file:org.jboss.capedwarf.prospectivesearch.MatchCollator.java
public List<Subscription> collate(Map<String, List<SerializableSubscription>> reducedResults) { List<SerializableSubscription> subscriptions = reducedResults.get(MatchMapper.KEY); if (subscriptions == null || subscriptions.isEmpty()) { return Collections.emptyList(); } else {/*from w w w.ja va 2s .co m*/ return Lists.transform(subscriptions, FN); } }
From source file:org.apache.gobblin.metrics.kafka.KafkaPusher.java
/** * Push all mbyte array messages to the Kafka topic. * @param messages List of byte array messages to push to Kakfa. *//*from w ww .j a v a2 s.c o m*/ public void pushMessages(List<byte[]> messages) { List<KeyedMessage<String, byte[]>> keyedMessages = Lists.transform(messages, new Function<byte[], KeyedMessage<String, byte[]>>() { @Nullable @Override public KeyedMessage<String, byte[]> apply(byte[] bytes) { return new KeyedMessage<String, byte[]>(topic, bytes); } }); this.producer.send(keyedMessages); }
From source file:io.anyway.sherlock.sqlparser.visitor.or.AbstractOrASTNode.java
/** * ????./*from w ww. j a va 2 s . c om*/ * * @return ??? */ public final List<ConditionContext> getCondition() { return Lists.transform(nestedConditions, new Function<List<Condition>, ConditionContext>() { @Override public ConditionContext apply(final List<Condition> input) { ConditionContext result = new ConditionContext(); for (Condition each : input) { result.add(each); } return result; } }); }
From source file:com.blacklocus.qs.worker.es.ElasticSearchQSInfoService.java
@Override public List<QSTaskModel> findTasks(FindTasks findTasks) { JresSearchBody search = new JresSearchBody().size(100); JresSearchReply reply = jres// w w w . j av a 2 s. co m .quest(new JresSearch(index, ElasticSearchQSLogService.INDEX_TYPE_TASK, search)); return Lists.transform(reply.getHitsAsType(QSTaskElasticSearchModel.class), new Function<QSTaskElasticSearchModel, QSTaskModel>() { @Override public QSTaskModel apply(QSTaskElasticSearchModel input) { return input.toNormalModel(); } }); }
From source file:com.google.template.soy.jssrc.dsl.SoyJsPluginUtils.java
/** * Applies the given print directive to {@code expr} and returns the result. * * @param generator The CodeChunk generator to use. * @param expr The expression to apply the print directive to. * @param directive The print directive to apply. * @param args Print directive args, if any. */// w w w .j a v a2 s.c o m public static CodeChunk.WithValue applyDirective(CodeChunk.Generator generator, CodeChunk.WithValue expr, SoyJsSrcPrintDirective directive, List<CodeChunk.WithValue> args) { List<JsExpr> argExprs = Lists.transform(args, TO_JS_EXPR); JsExpr applied = directive.applyForJsSrc(expr.singleExprOrName(), argExprs); RequiresCollector.IntoImmutableSet collector = new RequiresCollector.IntoImmutableSet(); expr.collectRequires(collector); for (CodeChunk.WithValue arg : args) { arg.collectRequires(collector); } if (directive instanceof SoyLibraryAssistedJsSrcPrintDirective) { for (String name : ((SoyLibraryAssistedJsSrcPrintDirective) directive).getRequiredJsLibNames()) { collector.add(GoogRequire.create(name)); } } ImmutableList.Builder<CodeChunk> initialStatements = ImmutableList.<CodeChunk>builder() .addAll(expr.initialStatements()); for (CodeChunk.WithValue arg : args) { initialStatements.addAll(arg.initialStatements()); } return fromExpr(applied, collector.get()).withInitialStatements(initialStatements.build()); }
From source file:org.estatio.app.budget.BudgetKeyItemImportExportService.java
@Action(semantics = SemanticsOf.SAFE) @ActionLayout(contributed = Contributed.AS_ASSOCIATION) public List<BudgetKeyItemImportExportLineItem> items(BudgetKeyItemImportExportManager manager) { return Lists.transform(new ArrayList<BudgetKeyItem>(manager.getBudgetKeyTable().getBudgetKeyItems()), toLineItem());//from w w w .j ava 2 s .co m }