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.isisaddons.wicket.timeline.cpt.ui.TimelineableCollectionAsTimeline.java

@Override
protected Set<String> getTimelineNames(final Collection<ObjectAdapter> entityList) {
    return Sets.newLinkedHashSet(
            Iterables.concat(Iterables.transform(entityList, TimelineableEventProvider.GET_Timeline_NAMES)));
}

From source file:org.jclouds.nodepool.config.BindJcloudsModules.java

@Provides
@Singleton// w w w  .  j a va 2  s .  co  m
@Backend
protected Set<Module> provideBackendModules(@Named(NodePoolProperties.BACKEND_MODULES) String moduleString) {
    return ImmutableSet
            .copyOf(Iterables.transform(Splitter.on(',').split(moduleString), new Function<String, Module>() {

                @Override
                public Module apply(String input) {
                    try {
                        return Module.class.cast(Class.forName(input).newInstance());
                    } catch (InstantiationException e) {
                        throw Throwables.propagate(e);
                    } catch (IllegalAccessException e) {
                        throw Throwables.propagate(e);
                    } catch (ClassNotFoundException e) {
                        throw Throwables.propagate(e);
                    }
                }
            }));
}

From source file:org.obiba.opal.web.magma.VariableEntityValueSetDtoFunction.java

@Override
public Magma.ValueSetsDto.ValueSetDto apply(final VariableEntity fromEntity) {
    final ValueSet valueSet = valueTable.getValueSet(fromEntity);

    Iterable<Magma.ValueSetsDto.ValueDto> valueDtosIter = Iterables.transform(variables,
            new Function<Variable, Magma.ValueSetsDto.ValueDto>() {

                @Override/*  ww w  .ja v a 2 s.  co m*/
                public Magma.ValueSetsDto.ValueDto apply(Variable fromVariable) {
                    String link = uriInfoPath.replace("valueSets", "valueSet/entity/"
                            + fromEntity.getIdentifier() + "/variable/" + fromVariable.getName() + "/value");
                    Value value = valueTable.getVariableValueSource(fromVariable.getName()).getValue(valueSet);
                    return asDto(link, value, filterBinary).build();
                }
            });

    // Do not add iterable directly otherwise the values will be fetched as many times it is iterated
    // (i.e. 2 times, see AbstractMessageLite.addAll()).
    ImmutableList.Builder<Magma.ValueSetsDto.ValueDto> valueDtos = ImmutableList.builder();
    for (Magma.ValueSetsDto.ValueDto dto : valueDtosIter) {
        valueDtos.add(dto);
    }

    return asDto(valueSet).addAllValues(valueDtos.build()) //
            .setTimestamps(asDto(valueSet.getTimestamps())).build();
}

From source file:org.robotframework.ide.eclipse.main.plugin.project.build.fix.ImportLibraryFixer.java

public static Collection<IMarkerResolution> createFixers(final IFile file, final String keywordName) {
    final RobotProject project = RedPlugin.getModelManager().getModel().createRobotProject(file.getProject());

    final Set<String> libs = newLinkedHashSet();
    new KeywordDefinitionLocator(file, new RobotModel()).locateKeywordDefinitionInLibraries(project,
            createKeywordsDetector(keywordName, libs));

    return newArrayList(Iterables.transform(libs, new Function<String, IMarkerResolution>() {

        @Override/*  ww w.  j a  va2 s .  co m*/
        public IMarkerResolution apply(final String libName) {
            return new ImportLibraryFixer(libName);
        }
    }));
}

From source file:shaded.org.openqa.selenium.remote.server.handler.FindChildElements.java

@Override
public Set<Map<String, String>> call() throws Exception {
    List<WebElement> elements = getElement().findElements(by);
    return Sets.newLinkedHashSet(Iterables.transform(elements, new Function<WebElement, Map<String, String>>() {
        public Map<String, String> apply(WebElement element) {
            return ImmutableMap.of("ELEMENT", getKnownElements().add(element));
        }//  w ww  .j  a v  a  2  s  .  c  o  m
    }));
}

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

@GET
public List<Opal.GroupDto> getGroups() {
    return Lists.newArrayList(
            Iterables.transform(subjectCredentialsService.getGroups(), new Function<Group, Opal.GroupDto>() {
                @Override//w ww  .  j  a v a2 s  . c om
                public Opal.GroupDto apply(Group group) {
                    return Dtos.asDto(group);
                }
            }));
}

From source file:org.isisaddons.wicket.fullcalendar2.cpt.ui.CalendarEventableCollectionAsFullCalendar2.java

@Override
protected Set<String> getCalendarNames(final Collection<ObjectAdapter> entityList) {
    return Sets.newLinkedHashSet(
            Iterables.transform(entityList, CalendarEventableEventProvider.GET_CALENDAR_NAME));
}

From source file:org.jclouds.cloudsigma.functions.SplitNewlinesAndReturnSecondField.java

@Override
public Set<String> apply(HttpResponse response) {
    return ImmutableSet
            .copyOf(Iterables.filter(Iterables.transform(super.apply(response), new Function<String, String>() {

                @Override/* w w w.  j  a va 2s. co  m*/
                public String apply(String arg0) {
                    if (arg0 == null)
                        return null;
                    Iterable<String> parts = Splitter.on(' ').split(arg0);
                    if (Iterables.size(parts) == 2)
                        return Iterables.get(parts, 1);
                    else if (Iterables.size(parts) == 1)
                        return Iterables.get(parts, 0);
                    return null;
                }

            }), Predicates.notNull()));
}

From source file:com.facebook.presto.util.IterableTransformer.java

public <T> IterableTransformer<T> transform(Function<? super E, T> function) {
    return new IterableTransformer<>(Iterables.transform(iterable, function));
}

From source file:co.cask.cdap.shell.completer.element.DatasetModuleNameCompleter.java

@Inject
public DatasetModuleNameCompleter(final DatasetModuleClient datasetModuleClient) {
    super(new Supplier<Collection<String>>() {
        @Override/*  w w w . j av a  2  s.co m*/
        public Collection<String> get() {
            try {
                List<DatasetModuleMeta> list = datasetModuleClient.list();
                return Lists.newArrayList(Iterables.transform(list, new Function<DatasetModuleMeta, String>() {
                    @Override
                    public String apply(DatasetModuleMeta input) {
                        return input.getName();
                    }
                }));
            } catch (IOException e) {
                return Lists.newArrayList();
            } catch (UnAuthorizedAccessTokenException e) {
                return Lists.newArrayList();
            }
        }
    });
}