Example usage for com.google.common.collect Lists transform

List of usage examples for com.google.common.collect Lists transform

Introduction

In this page you can find the example usage for com.google.common.collect Lists transform.

Prototype

@CheckReturnValue
public static <F, T> List<T> transform(List<F> fromList, Function<? super F, ? extends T> function) 

Source Link

Document

Returns a list that applies function to each element of fromList .

Usage

From source file:org.jpmml.converter.PMMLUtil.java

static public List<Value> createValues(List<String> values, final Value.Property property) {
    Function<String, Value> function = new Function<String, Value>() {

        @Override/*from w  w w  . jav  a  2  s  . co m*/
        public Value apply(String string) {
            Value value = new Value(string).setProperty(property);

            return value;
        }
    };

    return Lists.newArrayList(Lists.transform(values, function));
}

From source file:com.eharmony.matching.seeking.mapper.HibernateProjectedResultMapper.java

@SuppressWarnings("unchecked")
public <T, R> List<R> mapResults(List<?> objects, final Query<T, R> query) {
    final String[] returnFields = returnFields(query);
    return query.getEntityClass().equals(query.getReturnType()) ? (List<R>) objects
            : Lists.transform(objects, new Function<Object, R>() {
                @Override//from   w  w w.  j  av  a2 s . com
                public R apply(Object arg0) {
                    return mapResult(arg0, query, returnFields);
                }
            });
}

From source file:com.google.cloud.resourcemanager.PolicyMarshaller.java

@Override
protected Policy fromPb(com.google.api.services.cloudresourcemanager.model.Policy policyPb) {
    Map<Role, Set<Identity>> bindings = new HashMap<>();
    if (policyPb.getBindings() != null) {
        for (Binding bindingPb : policyPb.getBindings()) {
            bindings.put(Role.of(bindingPb.getRole()), ImmutableSet
                    .copyOf(Lists.transform(bindingPb.getMembers(), new Function<String, Identity>() {
                        @Override
                        public Identity apply(String s) {
                            return IDENTITY_VALUE_OF_FUNCTION.apply(s);
                        }/*from ww w .  ja  v a2 s  .c om*/
                    })));
        }
    }
    return new Builder(bindings, policyPb.getEtag(), policyPb.getVersion()).build();
}

From source file:org.opentestsystem.shared.monitoringalerting.service.impl.DiscreteIntakeServiceImpl.java

@Override
public String[] getDistinctComponents() {
    return Iterables.toArray(
            Lists.transform(this.discreteIntakeRepository.findByType(TYPE.COMPONENT), VALUE_TRANSFORMER),
            String.class);
}

From source file:org.jasig.portlet.survey.service.jpa.SurveyMapper.java

@Override
public List<SurveyDTO> toSurveyList(List<JpaSurvey> jpaList) {
    return Lists.transform(jpaList, new Function<JpaSurvey, SurveyDTO>() {
        @Override/*from   w w w.  j a  va  2 s . co  m*/
        public SurveyDTO apply(JpaSurvey jpaSurvey) {
            return toSurvey(jpaSurvey);
        }
    });
}

From source file:com.blacklocus.jres.request.search.query.JresBoolQuery.java

public JresBoolQuery mustNot(List<JresQuery> mustNot) {
    this.mustNot = Lists.transform(mustNot, new Function<JresQuery, Map<String, JresQuery>>() {
        @Override/*from   w w  w . ja  va2  s .c  o m*/
        public Map<String, JresQuery> apply(JresQuery input) {
            return ImmutableMap.of(input.queryType(), input);
        }
    });
    return this;
}

From source file:com.metamx.druid.merger.common.task.DefaultMergeTask.java

@Override
public File merge(final Map<DataSegment, File> segments, final File outDir) throws Exception {
    return IndexMerger.mergeQueryableIndex(
            Lists.transform(ImmutableList.copyOf(segments.values()), new Function<File, QueryableIndex>() {
                @Override/*from   w w  w . j a v a 2s .c o m*/
                public QueryableIndex apply(@Nullable File input) {
                    try {
                        return IndexIO.loadIndex(input);
                    } catch (Exception e) {
                        throw Throwables.propagate(e);
                    }
                }
            }), aggregators.toArray(new AggregatorFactory[aggregators.size()]), outDir);
}

From source file:org.grouplens.lenskit.eval.metrics.ResultConverter.java

ResultConverter(Class<T> type, List<Column> cols) {
    resultType = type;/*from w  ww. j a v  a2  s . c  o  m*/
    columns = ImmutableList.copyOf(cols);
    columnLabels = Lists.transform(columns, new Function<Column, String>() {
        @Nullable
        @Override
        public String apply(@Nullable Column input) {
            assert input != null;
            return input.getName();
        }
    });
}

From source file:com.chessix.vas.service.RdbmsStorage.java

@Override
public List<Integer> accountValues(final String clasId) {
    final List<Integer> result = Lists.newLinkedList();
    int page = 0;
    Page<Account> accounts;/*from   w  w  w  .j av a 2  s .  co m*/
    do {
        accounts = dbService.findAccountsByClas(clasId, new PageRequest(page, PAGE_SIZE));
        result.addAll(Lists.transform(accounts.getContent(), new Function<Account, Integer>() {

            @Override
            public Integer apply(final Account input) {
                return input.getBalance();
            }
        }));

        page += 1;
    } while (accounts.hasNext());

    return result;
}

From source file:io.druid.emitter.graphite.GraphiteEmitterModule.java

@Provides
@ManageLifecycle/* w  ww .  ja v  a2s .c  o m*/
@Named(EMITTER_TYPE)
public Emitter getEmitter(GraphiteEmitterConfig graphiteEmitterConfig, ObjectMapper mapper,
        final Injector injector) {
    List<Emitter> emitters = Lists.transform(graphiteEmitterConfig.getAlertEmitters(),
            new Function<String, Emitter>() {
                @Override
                public Emitter apply(String s) {
                    return injector.getInstance(Key.get(Emitter.class, Names.named(s)));
                }
            });
    return new GraphiteEmitter(graphiteEmitterConfig, emitters);
}