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:com.ning.billing.invoice.dao.InvoiceModelDaoHelper.java

public static BigDecimal getCBAAmount(final InvoiceModelDao invoiceModelDao) {
    return InvoiceCalculatorUtils.computeInvoiceAmountCredited(Iterables
            .transform(invoiceModelDao.getInvoiceItems(), new Function<InvoiceItemModelDao, InvoiceItem>() {
                @Override//from w  w w.j  a  v a2s  .c o m
                public InvoiceItem apply(final InvoiceItemModelDao input) {
                    return InvoiceItemFactory.fromModelDao(input);
                }
            }));
}

From source file:com.google.errorprone.predicates.TypePredicates.java

/** Match types that are exactly equal to any of the given types. */
public static TypePredicate isExactTypeAny(Iterable<String> types) {
    return new ExactAny(Iterables.transform(types, GET_TYPE));
}

From source file:org.zalando.github.spring.pagination.LinkRelationExtractor.java

public Optional<LinkRelation> extractLinkRelation(String linkHeaderValue, String relation) {
    Iterable<String> splittedHeaderIterable = splitter.split(linkHeaderValue);
    Iterable<LinkRelation> linkRelations = Iterables.transform(splittedHeaderIterable, transformer);
    linkRelations = Iterables.filter(linkRelations, new RelationsPredicate(relation));
    return Optional.fromNullable(Iterables.getFirst(linkRelations, null));
}

From source file:com.google.devtools.build.xcode.util.Interspersing.java

/**
 * Similar to {@link #prependEach(String, Iterable)}, but also converts each item in the sequence
 * to a string.//from w w w . j  a v a 2 s.  c o m
 */
public static <E> Iterable<String> prependEach(String what, Iterable<E> sequence,
        Function<? super E, String> toString) {
    return prependEach(what, Iterables.transform(sequence, toString));
}

From source file:org.graylog.collector.file.naming.NumberSuffixStrategy.java

public NumberSuffixStrategy(Set<Path> basePaths) {
    this.basePaths = Iterables.transform(basePaths, new Function<Path, Path>() {
        @Nullable//from  w w w  . j a va 2s  . c o m
        @Override
        public Path apply(Path path) {
            return path.normalize().toAbsolutePath();
        }
    });
}

From source file:com.b2international.commons.collections.Collections3.java

/**Executes the given procedure on every element of the iterable. More like a closure.*/
public static <F> void forEach(final Iterable<? extends F> fromIterable, final Procedure<? super F> f) {

    Iterables.transform(Preconditions.checkNotNull(fromIterable, "Iterable argument cannot be null."),
            Preconditions.checkNotNull(f, "Function argument cannot be null")).toString();

}

From source file:co.cask.cdap.data2.transaction.Transactions.java

/**
 * Handy method to create {@link TransactionExecutor} (See TEPHRA-71).
 *//*from   w ww  .  jav  a2  s.c  o m*/
public static TransactionExecutor createTransactionExecutor(TransactionExecutorFactory factory,
        Iterable<? extends TransactionAware> txAwares) {
    return factory.createExecutor(Iterables.transform(txAwares, Functions.<TransactionAware>identity()));
}

From source file:com.github.x3333.dagger.aop.internal.Util.java

/**
 * Convert a {@link AnnotationMirror}s to {@link AnnotationSpec}.
 *//*from   w w w .  ja v  a  2  s  . c om*/
static Iterable<AnnotationSpec> toSpec(final Iterable<? extends AnnotationMirror> mirrors) {
    return Iterables.transform(mirrors, AnnotationSpec::get);
}

From source file:com.google.cloud.genomics.dataflow.functions.ExtractSimilarCallsets.java

@VisibleForTesting
static ImmutableList<String> getSamplesWithVariant(Variant variant) {
    return ImmutableList.copyOf(Iterables.transform(CallFilters.getSamplesWithVariantOfMinGenotype(variant, 1),
            new Function<Call, String>() {

                @Override/*w  w w .ja  v a 2  s .co  m*/
                public String apply(Call call) {
                    return call.getCallSetName();
                }

            }));
}

From source file:com.eucalyptus.auth.ws.EuareRequestLoggingFilter.java

private static Iterable<String> buildActionNVPs(final String action) {
    return Iterables.unmodifiableIterable(Iterables.transform(Arrays.asList(OperationParameter.values()),
            Functions.compose(Strings.append("=" + action), Functions.toStringFunction())));
}