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:io.prestosql.server.PluginClassLoader.java
public PluginClassLoader(List<URL> urls, ClassLoader spiClassLoader, Iterable<String> spiPackages) { this(urls, spiClassLoader, spiPackages, Iterables.transform(spiPackages, PluginClassLoader::classNameToResource)); }
From source file:org.gradle.plugins.ide.idea.internal.IdeaNameDeduper.java
public void configureRoot(Project rootProject) { Set<Project> projects = Sets.filter(rootProject.getAllprojects(), HAS_IDEA_PLUGIN); Iterable<IdeaModule> ideaModules = Iterables.transform(projects, GET_IDEA_MODULE); HierarchicalElementDeduplicator<IdeaModule> deduplicator = new HierarchicalElementDeduplicator<IdeaModule>( new IdeaDeduplicationAdapter()); Map<IdeaModule, String> deduplicated = deduplicator.deduplicate(ideaModules); for (Map.Entry<IdeaModule, String> entry : deduplicated.entrySet()) { entry.getKey().setName(entry.getValue()); }// ww w. j a v a2s. co m }
From source file:org.obiba.opal.core.domain.OpalGeneralConfig.java
public List<String> getLocalesAsString() { return Lists.newArrayList(Iterables.transform(getLocales(), new Function<Locale, String>() { @Override//w w w . java 2s.c o m public String apply(Locale locale) { return locale.getLanguage(); } })); }
From source file:com.eucalyptus.util.CollectionUtils.java
/** * Apply the given function for each item in the iterable. * * <p>This method is an anti-pattern as the function is really an effect (it * can only be useful for its side effect)</p> * * @param iterable The iterable/*from ww w.ja v a 2 s . co m*/ * @param function The function to apply * @param <T> The iterable type */ public static <T> void each(final Iterable<T> iterable, final Function<? super T, ?> function) { Iterables.size(Iterables.transform(iterable, function)); // transform is lazy }
From source file:org.gradle.internal.component.NoMatchingConfigurationSelectionException.java
private static String generateMessage(AttributeContainer fromConfigurationAttributes, AttributesSchema consumerSchema, ComponentResolveMetadata targetComponent, List<String> configurationNames) { List<ConfigurationMetadata> configurations = new ArrayList<ConfigurationMetadata>( configurationNames.size());/*from w w w. ja v a2 s . c o m*/ for (String name : configurationNames) { ConfigurationMetadata targetComponentConfiguration = targetComponent.getConfiguration(name); if (targetComponentConfiguration.isCanBeConsumed() && !targetComponentConfiguration.getAttributes().isEmpty()) { configurations.add(targetComponentConfiguration); } } Set<String> requestedAttributes = Sets .newTreeSet(Iterables.transform(fromConfigurationAttributes.keySet(), ATTRIBUTE_NAME)); StringBuilder sb = new StringBuilder( "Unable to find a matching configuration in '" + targetComponent + "' :"); if (configurations.isEmpty()) { sb.append(" None of the consumable configurations have attributes."); } else { sb.append("\n"); int maxConfLength = maxLength(configurationNames); // We're sorting the names of the configurations and later attributes // to make sure the output is consistently the same between invocations for (final String config : configurationNames) { formatConfiguration(sb, fromConfigurationAttributes, consumerSchema, configurations, requestedAttributes, maxConfLength, config); } } return sb.toString(); }
From source file:org.geogit.storage.sqlite.PathToRootWalker.java
@Override public List<ObjectId> next() { List<ObjectId> curr = Lists.newArrayList(); List<ObjectId> next = Lists.newArrayList(); while (!q.isEmpty()) { ObjectId node = q.poll();//from ww w . j a v a 2s . com curr.add(node); Iterables.addAll(next, Iterables.transform(graph.outgoing(node.toString(), cx), StringToObjectId.INSTANCE)); } seen.addAll(curr); q.addAll(next); return curr; }
From source file:org.sonar.server.debt.DebtModelLookup.java
private static List<DebtCharacteristic> toCharacteristics(Collection<CharacteristicDto> dtos) { return newArrayList(Iterables.transform(dtos, new Function<CharacteristicDto, DebtCharacteristic>() { @Override//from w w w. j ava2 s. c o m public DebtCharacteristic apply(@Nullable CharacteristicDto input) { return input != null ? toCharacteristic(input) : null; } })); }
From source file:com.polymathiccoder.servo.publish.influxdb.util.NetflixServoUtils.java
public static MetricTransformation commonTagsDecoration() { return (metric) -> { final Set<Tag> tags = Sets.newHashSet(Iterables.transform(metric.getConfig().getTags(), (it) -> new BasicTag(it.getKey(), it.getValue()))); // Add legacy Atlas tag if (isCounter(metric)) { tags.add(ATLAS_COUNTER_TAG); } else if (isGauge(metric)) { tags.add(ATLAS_GAUGE_TAG);//from w ww .j a va 2s . c o m } else if (isRate(metric)) { tags.add(ATLAS_COUNTER_TAG); } // Add cluster tag final String cluster = System.getenv("NETFLIX_CLUSTER"); tags.add(new BasicTag(CLUSTER, (cluster == null) ? UNKNOWN : cluster)); // Add node tag try { tags.add(new BasicTag(NODE, InetAddress.getLocalHost().getHostName())); } catch (final UnknownHostException unknownHostException) { tags.add(new BasicTag(NODE, UNKNOWN)); } return new Metric(metric.getConfig().getName(), BasicTagList.of(tags.toArray(new Tag[tags.size()])), metric.getTimestamp(), metric.getNumberValue()); }; }
From source file:net.hillsdon.reviki.wiki.macros.AbstractListOfPagesMacro.java
public final String handle(final PageInfo page, /* mutable */ String remainder) throws Exception { if (remainder != null && page != null) { remainder = remainder.replace("@_currentPage", page.getPath()); }// ww w .j ava 2 s.c o m List<String> pages = new ArrayList<String>(getPages(remainder)); sort(pages); return Joiner.on("\n").join(Iterables.transform(pages, new Function<String, String>() { public String apply(final String page) { return " * [[" + page + "]]"; } })); }
From source file:org.obiba.opal.web.taxonomy.Dtos.java
public static Opal.TaxonomiesDto.TaxonomySummaryDto asVocabularySummaryDto(Taxonomy taxonomy) { Opal.TaxonomiesDto.TaxonomySummaryDto.Builder builder = Opal.TaxonomiesDto.TaxonomySummaryDto.newBuilder(); builder.setName(taxonomy.getName()); builder.addAllTitle(toLocaleTextDtoList(taxonomy.getTitle())); if (taxonomy.hasVocabularies()) { builder.addAllVocabularySummaries(Iterables.transform(taxonomy.getVocabularies(), new Function<Vocabulary, Opal.TaxonomiesDto.TaxonomySummaryDto.VocabularySummaryDto>() { @Nullable//from w w w.j a v a2 s . c om @Override public Opal.TaxonomiesDto.TaxonomySummaryDto.VocabularySummaryDto apply( @Nullable Vocabulary input) { return asSummaryDto(input); } })); } return builder.build(); }