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.facebook.buck.util.PatternsMatcher.java

public PatternsMatcher(Iterable<String> rawPatterns) {
    patterns = Iterables.transform(rawPatterns, Pattern::compile);
    hasPatterns = rawPatterns.iterator().hasNext();
}

From source file:com.metamx.collections.spatial.search.GutmanSearchStrategy.java

@Override
public Iterable<ImmutableBitmap> search(ImmutableNode node, Bound bound) {
    if (bound.getLimit() > 0) {
        return Iterables.transform(breadthFirstSearch(node, bound),
                new Function<ImmutableNode, ImmutableBitmap>() {
                    @Override//from w ww .j  a va 2s  .c  o m
                    public ImmutableBitmap apply(ImmutableNode immutableNode) {
                        return immutableNode.getImmutableBitmap();
                    }
                });
    }

    return Iterables.transform(depthFirstSearch(node, bound), new Function<ImmutablePoint, ImmutableBitmap>() {
        @Override
        public ImmutableBitmap apply(ImmutablePoint immutablePoint) {
            return immutablePoint.getImmutableBitmap();
        }
    });
}

From source file:org.obiba.opal.core.security.OpalPermissions.java

public OpalPermissions(URI uri, Iterable<AclAction> actions) {
    this.uri = uri;
    perms = Iterables.transform(actions, new Function<AclAction, String>() {

        @Override//ww w.  j ava  2  s. c  o  m
        public String apply(AclAction input) {
            return input.toString();
        }

    });
}

From source file:com.facebook.buck.rules.Builder.java

public ListenableFuture<List<BuildRuleSuccess>> buildRules(final BuildEngine buildEngine,
        Iterable<BuildRule> rules, final BuildContext context) {
    return Futures.allAsList(
            Iterables.transform(rules, new Function<BuildRule, ListenableFuture<BuildRuleSuccess>>() {
                @Override/*from  w w  w  .j a  va2  s.co m*/
                public ListenableFuture<BuildRuleSuccess> apply(BuildRule rule) {
                    return buildEngine.build(context, rule);
                }
            }));
}

From source file:ezbake.amino.cli.commands.CreateGroup.java

public static Set<TGroupMember> parseGroupMembers(Collection<String> groupMembers) {
    return ImmutableSet.copyOf(Collections2.transform(groupMembers, new Function<String, TGroupMember>() {
        @Override//w  w w.j av a  2 s .  com
        public TGroupMember apply(String member) {
            String[] memberAndRole = member.split(":");
            String name = memberAndRole[0];

            Set<TGroupRole> roles = ImmutableSet.copyOf(Iterables
                    .transform(Splitter.on(',').split(memberAndRole[1]), new Function<String, TGroupRole>() {
                        @Override
                        public TGroupRole apply(String name) {
                            return TGroupRole.valueOf(name);
                        }
                    }));
            return new TGroupMember(name, roles);
        }
    }));
}

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

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

From source file:org.eclipse.xtext.resource.impl.AbstractCompoundSelectable.java

@Override
public Iterable<IEObjectDescription> getExportedObjects() {
    return Iterables.concat(
            Iterables.transform(getSelectables(), new Function<ISelectable, Iterable<IEObjectDescription>>() {
                @Override/*from  w w  w. ja va2s  .c o m*/
                public Iterable<IEObjectDescription> apply(ISelectable from) {
                    if (from != null)
                        return from.getExportedObjects();
                    return Collections.emptyList();
                }
            }));
}

From source file:org.apache.isis.core.runtime.services.DeweyOrderUtil.java

static <V> List<Map.Entry<String, V>> deweySorted(Set<Map.Entry<String, V>> keys) {
    if (keys == null) {
        throw new IllegalArgumentException("Keys cannot be null");
    }/*from  w w w. j av  a2 s.co m*/
    final Iterable<Parsed<V>> parsedIter = Iterables.transform(keys,
            new Function<Map.Entry<String, V>, Parsed<V>>() {
                @Override
                public Parsed<V> apply(Map.Entry<String, V> input) {
                    return new Parsed(input);
                }
            });

    final SortedSet<Parsed<V>> parseds = Sets.newTreeSet(parsedIter);
    final Iterable<Map.Entry<String, V>> transform = Iterables.transform(parseds,
            DeweyOrderUtil.<V>toMapEntry());
    return Lists.newArrayList(transform);
}

From source file:org.obiba.opal.web.system.subject.SubjectProfilesResource.java

@GET
public List<Opal.SubjectProfileDto> getAll() {
    return Lists.newArrayList(Iterables.transform(subjectProfileService.getProfiles(),
            new Function<SubjectProfile, Opal.SubjectProfileDto>() {
                @Override/*ww w.  j  a  v  a2 s. co  m*/
                public Opal.SubjectProfileDto apply(SubjectProfile profile) {
                    return Dtos.asDto(profile);
                }
            }));
}

From source file:com.facebook.buck.cxx.AbstractCxxCompilationDatabaseEntry.java

@Value.Derived
public String getCommand() {
    return Joiner.on(' ').join(Iterables.transform(getArguments(), Escaper.SHELL_ESCAPER));
}