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:com.eucalyptus.compute.identifier.DispatchingResourceIdentifierCanonicalizer.java
@Override public String getName() { return Joiner.on(",").join(Iterables.transform(canonicalizers, ResourceIdentifiers.ResourceIdentifierCanonicalizerToName.INSTANCE)); }
From source file:org.jclouds.atmos.blobstore.functions.ResourceMetadataListToDirectoryEntryList.java
public BoundedSet<DirectoryEntry> apply(org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata> from) { return new BoundedLinkedHashSet<DirectoryEntry>( Iterables.transform(from, new Function<StorageMetadata, DirectoryEntry>() { public DirectoryEntry apply(StorageMetadata from) { FileType type = (from.getType() == StorageType.FOLDER || from.getType() == StorageType.RELATIVE_PATH) ? FileType.DIRECTORY : FileType.REGULAR; return new DirectoryEntry(from.getProviderId(), type, from.getName()); }//from w w w .j a va 2 s . c o m }), from.getNextMarker()); }
From source file:com.proofpoint.event.collector.validation.ValidUriValidator.java
@Override public void initialize(ValidUri constraintAnnotation) { validSchemes = ImmutableSet/* w w w .j a v a 2s.c om*/ .copyOf(Iterables.transform(Arrays.asList(constraintAnnotation.schemes()), TO_LOWER_CASE)); }
From source file:com.yahoo.yqlplus.engine.internal.plan.types.base.MethodDispatcher.java
private String toKey(String methodName, Iterable<Type> argumentTypes) { StringBuilder out = new StringBuilder(); out.append(methodName).append('('); Joiner.on(",").appendTo(out, Iterables.transform(argumentTypes, new Function<Type, String>() { @Override//from w w w . ja v a 2 s .c o m public String apply(Type input) { return input.getDescriptor(); } })); out.append(')'); return out.toString(); }
From source file:org.jclouds.openstack.swift.blobstore.functions.ResourceToObjectList.java
public PageSet<ObjectInfo> apply(PageSet<? extends StorageMetadata> list) { return new PageSetImpl<ObjectInfo>(Iterables.transform(list, new Function<StorageMetadata, ObjectInfo>() { public ObjectInfo apply(StorageMetadata from) { return resource2ObjectMd.apply(from); }//from ww w .j av a2s .com }), list.getNextMarker()); }
From source file:org.isisaddons.app.kitchensink.dom.mixins.mixin.Person_firstLove.java
@Action(semantics = SemanticsOf.SAFE) @ActionLayout(contributed = Contributed.AS_ASSOCIATION) public FoodStuff $$() { final List<FoodStuff> loves = Lists.newArrayList(Iterables.transform( Iterables.filter(preferences.listAllPreferences(), Predicates.preferenceOf(person, Preference.PreferenceType.LOVE)), Preference.Functions.food())); return loves.isEmpty() ? null : loves.get(0); }
From source file:com.opengamma.integration.tool.portfolio.xml.v1_0.conversion.PortfolioDocumentConverterV1_0.java
@Override public Iterable<VersionedPortfolioHandler> convert(PortfolioDocumentV1_0 portfolioDocument) { Iterable<Portfolio> portfolios = extractPortfolios(portfolioDocument); Iterable<VersionedPortfolioHandler> transformed = Iterables.transform(portfolios, new PortfolioExtractor()); // Portfolios with errors will leave nulls in the iterable which we need to remove return Iterables.filter(transformed, new Predicate<VersionedPortfolioHandler>() { @Override/*from w w w . j ava 2s. com*/ public boolean apply(VersionedPortfolioHandler versionedPortfolioHandler) { return versionedPortfolioHandler != null; } }); }
From source file:org.asoem.greyfish.utils.collect.LinearSequences.java
/** * Create a crossover product between two {@code Iterables} with crossovers at given {@code indices}. This means * that both {@code Iterable}s in the returned product are a combination of the input iterables in such a way, that * the constructed iterable switches the input iterable at each given position. Both input {@code Iterable}s will be * zipped with {@link Products#zip(Iterable, Iterable)}. Therefore the returned {@code Iterable}s will have the same * size equal to the size of the input iterable with the fewest elements. * * @param x The first Iterable//w w w . ja v a2 s .c o m * @param y The second Iterable * @param indices the indices at which to do the crossovers * @param <E> the type of the elements in {@code Iterable}s * @return a product of Iterables with crossovers at the given indices */ public static <E> Product2<Iterable<E>, Iterable<E>> crossover(final Iterable<E> x, final Iterable<E> y, final Set<Integer> indices) { checkNotNull(x); checkNotNull(y); checkNotNull(indices); final Iterable<Product2<E, E>> zipped = Products.zip(x, y); if (indices.isEmpty()) { return Products.unzip(zipped); } else { final FunctionalList<Range<Integer>> ranges = ImmutableFunctionalList.copyOf( Iterables.transform(Iterables.partition(Ordering.natural().immutableSortedCopy(indices), 2), new Function<List<Integer>, Range<Integer>>() { @Nullable @Override public Range<Integer> apply(@Nullable final List<Integer> input) { assert input != null; return input.size() == 2 ? Range.closed(input.get(0), input.get(1)) : Range.atLeast(input.get(0)); } })); return Products.unzip(Iterables.transform(Products.zipWithIndex(zipped), new Function<Product2<Product2<E, E>, Integer>, Product2<E, E>>() { @Nullable @Override public Product2<E, E> apply(@Nullable final Product2<Product2<E, E>, Integer> input) { assert input != null; return ranges.any(new Predicate<Range<Integer>>() { @Override public boolean apply(@Nullable final Range<Integer> range) { assert range != null; return range.contains(input.second()); } }) ? Products.swap(input.first()) : input.first(); } })); } }
From source file:org.apache.whirr.service.jclouds.SaveHttpResponseTo.java
public SaveHttpResponseTo(String dir, String file, String method, URI endpoint, Multimap<String, String> headers) { super(String.format( "({md} %s && {cd} %s && [ ! -f %s ] && " + "curl -C - -s -q -L --connect-timeout 10 --max-time 600 -X %s -s --retry 20 %s %s >%s)\n", dir, dir, file, method, Joiner.on(' ').join( Iterables.transform(headers.entries(), new Function<Map.Entry<String, String>, String>() { @Override public String apply(Map.Entry<String, String> from) { return String.format("-H \"%s: %s\"", from.getKey(), from.getValue()); }//from w w w .j a v a 2s.c o m })), endpoint.toASCIIString(), file)); }
From source file:org.polarsys.reqcycle.types.impl.TypesManager.java
@Override public Iterable<IType> getAllTypes() { Iterable<Iterable<IType>> transform = Iterables.transform(providers, new ProviderToITypes()); Iterable<IType> result = Iterables.concat(transform); return Iterables.unmodifiableIterable(Iterables.concat(allTypes.values(), result)); }