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:org.richfaces.cdk.util.MorePredicates.java

public static <S, D> Predicate<D> none(Iterable<S> options, Function<S, Predicate<D>> function) {
    if (options == null || Iterables.isEmpty(options)) {
        return Predicates.alwaysTrue();
    }//from  w  w w .  ja  v a2s .  c  o  m

    Predicate<D> compositePredicate = Predicates.or(Iterables.transform(options, function));
    return Predicates.not(compositePredicate);
}

From source file:io.github.holasylk.collect.guava.test.LabelledFactory.java

@Override
default Iterable<Object[]> get() {
    //noinspection StaticPseudoFunctionalStyleMethod
    return Iterables.transform(createEntries().entrySet(), e -> new Object[] { e.getKey(), e.getValue() });
}

From source file:com.google.gerrit.acceptance.rest.project.RefAssert.java

private static Iterable<String> refs(Iterable<? extends RefInfo> infos) {
    return Iterables.transform(infos, b -> b.ref);
}

From source file:org.fenixedu.academic.domain.CurricularYearList.java

public static CurricularYearList internalize(String data) {

    Iterable<Integer> years = Iterables.transform(SPLITTER.split(data), new Function<String, Integer>() {

        @Override//w  w  w. ja v  a2 s . co m
        public Integer apply(String str) {
            return Integer.parseInt(str);
        }

    });

    return new CurricularYearList(years);

}

From source file:com.facebook.buck.rules.coercer.ListConcatenatingCoercer.java

@Override
public Object concat(Iterable<Object> elements) {
    Iterable<List<Object>> lists = Iterables.transform(elements, List.class::cast);
    return ImmutableList.copyOf(Iterables.concat(lists));
}

From source file:com.atlassian.jira.rest.client.api.domain.EntityHelper.java

public static Iterable<String> toFileNamesList(Iterable<? extends Attachment> attachments) {
    return Iterables.transform(attachments, new Function<Attachment, String>() {
        @Override/*  www. j  a  v  a  2  s .co m*/
        public String apply(Attachment a) {
            return a.getFilename();
        }
    });
}

From source file:org.apache.isis.security.shiro.util.Util.java

public static Map<String, List<String>> parse(String permissionsByRoleStr) {
    Map<String, List<String>> perms = Maps.newHashMap();
    for (String roleAndPermsStr : Splitter.on(";").split(permissionsByRoleStr)) {
        final Iterable<String> split = Splitter.on("=").split(roleAndPermsStr);
        final String[] roleAndPerms = Iterables.toArray(split, String.class);
        if (roleAndPerms.length != 2) {
            continue;
        }// ww w.j a v a  2s .  c om
        final String role = roleAndPerms[0].trim();
        final String permStr = roleAndPerms[1].trim();
        perms.put(role, Lists.newArrayList(Iterables.transform(Splitter.on(",").split(permStr), TRIM)));
    }
    return perms;
}

From source file:ratpack.server.internal.ServerEnvironment.java

@SafeVarargs
@SuppressWarnings("varargs")
private static <T> T get(T defaultValue, Predicate<? super T> accept, Supplier<T>... suppliers) {
    return Iterables.find(Iterables.transform(Arrays.asList(suppliers), Supplier::get), accept::test,
            defaultValue);/*  ww  w  .  j a va 2  s . c  o  m*/
}

From source file:com.github.ferstl.maven.pomenforcers.util.CommaSeparatorUtils.java

public static <T> String join(Iterable<T> parts, Function<T, String> transformer) {
    Iterable<String> convertedParts = Iterables.transform(parts, transformer);
    return COMMA_JOINER.join(convertedParts);
}

From source file:org.trancecode.concurrent.ParallelIterables.java

public static <T> Iterable<T> get(final Iterable<Future<T>> futures) {
    final Function<Future<T>, T> function = FutureFunctions.get();
    return Iterables.transform(futures, function);
}