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:com.metamx.druid.merger.coordinator.WorkerWrapper.java

public Set<String> getRunningTasks() {
    return Sets.newHashSet(Lists.transform(statusCache.getCurrentData(), cacheConverter));
}

From source file:org.spka.cursus.publish.website.ConsoleMain.java

public boolean run(String[] files) throws IOException, ImportException, ExportException {
    return run(Lists.transform(Arrays.asList(files), new Function<String, File>() {
        @Override// www  .j  a  v a2  s . c o m
        @Nullable
        public File apply(@Nullable String file) {
            return new File(file);
        }
    }));
}

From source file:tv.icntv.grade.film.InctvGrade.java

@Override
public int run(String[] strings) throws Exception {

    try {/*from  ww w . java  2s .c o  m*/
        ToolRunner.run(configuration, new TableConcurrencyJob(), strings);
    } catch (Exception e) {
    }

    List<String> list = Lists.newArrayList(Splitter.on(",").split(configuration.get(cdn_tables)));
    List<String> results = Lists.transform(list, new Function<String, String>() {
        @Override
        public String apply(@Nullable java.lang.String input) {
            return String.format(configuration.get("hdfs.directory.base.db"), new Date(), input);
        }
    });
    //topN
    try {
        ToolRunner.run(configuration, new TopNJob(),
                new String[] { Joiner.on(",").join(results),
                        String.format(configuration.get("hdfs.directory.num.middle"), new Date()),
                        String.format(configuration.get("hdfs.directory.num.result"), new Date()) });
    } catch (Exception e) {
        return 1;
    }
    //recommend data generate data
    String baseCfData = String.format(configuration.get("hdfs.directory.base.score"), new Date());
    String output = String.format(configuration.get("icntv.cf.recommend.directory.target"), new Date());
    String temp = String.format(configuration.get("icntv.cf.recommend.directory.temp"), new Date());
    String optional = getParameterForCf(configuration, baseCfData, output, temp);
    try {
        ToolRunner.run(configuration,
                (Tool) ReflectionUtils.newInstance(configuration.get("recommend.job.className")),
                new String[] { Joiner.on(",").join(results), baseCfData, optional, output, temp });
    } catch (Exception e) {
        return 1;
    }
    //?
    String middleDirectory = String.format(configuration.get("icntv.correlate.input"), new Date());
    try {
        ToolRunner.run(configuration,
                (Tool) ReflectionUtils.newInstance(configuration.get("correlate.job.className")),
                new String[] { Joiner.on(",").join(results), middleDirectory,
                        getParameterForCorrelate(configuration, middleDirectory,
                                String.format(configuration.get("icntv.correlate.fp.growth.output"),
                                        new Date())),
                        String.format(configuration.get("icntv.correlate.output"), new Date()) });
    } catch (Exception e) {
        return 1;
    }
    return 0; //To change body of implemented methods use File | Settings | File Templates.
}

From source file:software.betamax.ConfigurationBuilder.java

public ConfigurationBuilder withProperties(Properties properties) {
    if (properties.containsKey("betamax.tapeRoot")) {
        tapeRoot(new File(properties.getProperty("betamax.tapeRoot")));
    }/*from  w w  w .  j  a  v  a2s.c om*/

    if (properties.containsKey("betamax.defaultMode")) {
        defaultMode(TapeMode.valueOf(properties.getProperty("betamax.defaultMode")));
    }

    if (properties.containsKey("betamax.defaultMatchRules")) {
        List<MatchRule> rules = Lists.transform(
                Splitter.on(",").splitToList(properties.getProperty("betamax.defaultMatchRules")),
                new Function<String, MatchRule>() {
                    @Override
                    public MatchRule apply(String input) {
                        return MatchRules.valueOf(input);
                    }
                });
        defaultMatchRule(ComposedMatchRule.of(rules));
    }

    if (properties.containsKey("betamax.ignoreHosts")) {
        ignoreHosts(Splitter.on(",").splitToList(properties.getProperty("betamax.ignoreHosts")));
    }

    if (properties.containsKey("betamax.ignoreLocalhost")) {
        ignoreLocalhost(Boolean.valueOf(properties.getProperty("betamax.ignoreLocalhost")));
    }

    if (properties.containsKey("betamax.proxyHost")) {
        proxyHost(properties.getProperty("betamax.proxyHost"));
    }

    if (properties.containsKey("betamax.proxyPort")) {
        proxyPort(TypedProperties.getInteger(properties, "betamax.proxyPort"));
    }

    if (properties.containsKey("betamax.proxyTimeoutSeconds")) {
        proxyTimeoutSeconds(TypedProperties.getInteger(properties, "betamax.proxyTimeoutSeconds"));
    }

    if (properties.containsKey("betamax.requestBufferSize")) {
        requestBufferSize(TypedProperties.getInteger(properties, "betamax.requestBufferSize"));
    }

    if (properties.containsKey("betamax.sslEnabled")) {
        sslEnabled(TypedProperties.getBoolean(properties, "betamax.sslEnabled"));
    }

    return this;
}

From source file:org.sonar.server.project.ws.SearchMyProjectsDataLoader.java

SearchMyProjectsData load(DbSession dbSession, SearchMyProjectsRequest request) {
    SearchMyProjectsData.Builder data = builder();
    ProjectsResult searchResult = searchProjects(dbSession, request);
    List<ComponentDto> projects = searchResult.projects;
    List<String> projectUuids = Lists.transform(projects, ComponentDto::projectUuid);
    List<ComponentLinkDto> projectLinks = dbClient.componentLinkDao().selectByComponentUuids(dbSession,
            projectUuids);//  w  w  w. j  a  v a 2s . c  o  m
    List<SnapshotDto> snapshots = dbClient.snapshotDao().selectLastAnalysesByRootComponentUuids(dbSession,
            projectUuids);
    MetricDto gateStatusMetric = dbClient.metricDao().selectOrFailByKey(dbSession,
            CoreMetrics.ALERT_STATUS_KEY);
    MeasureQuery measureQuery = MeasureQuery.builder().setProjectUuids(projectUuids)
            .setMetricId(gateStatusMetric.getId()).build();
    List<MeasureDto> qualityGates = dbClient.measureDao().selectByQuery(dbSession, measureQuery);

    data.setProjects(projects).setProjectLinks(projectLinks).setSnapshots(snapshots)
            .setQualityGates(qualityGates).setTotalNbOfProjects(searchResult.total);

    return data.build();
}

From source file:org.apache.calcite.sql.validate.SqlUserDefinedAggFunction.java

@SuppressWarnings("deprecation")
public List<RelDataType> getParameterTypes(final RelDataTypeFactory typeFactory) {
    return Lists.transform(function.getParameters(), new Function<FunctionParameter, RelDataType>() {
        public RelDataType apply(FunctionParameter input) {
            return input.getType(typeFactory);
        }/*from   w ww . j  ava2s. c  om*/
    });
}

From source file:com.feedzai.commons.sql.abstraction.engine.impl.PostgreSqlTranslator.java

@Override
public String translate(AlterColumn ac) {
    final DbColumn column = ac.getColumn();
    final Expression table = ac.getTable();
    final Name name = new Name(column.getName());

    inject(table, name);//from   w w w.  j  a va2s .com

    StringBuilder sb = new StringBuilder("ALTER TABLE ").append(table.translate()).append(" ALTER COLUMN ")
            .append(name.translate()).append(" TYPE ").append(translate(column)).append("; ");

    if (!column.getColumnConstraints().isEmpty()) {
        sb.append("ALTER TABLE ").append(table.translate()).append(" ALTER COLUMN ").append(name.translate())
                .append(" SET ");

        List<Object> trans = Lists.transform(column.getColumnConstraints(),
                new com.google.common.base.Function<DbColumnConstraint, Object>() {
                    @Override
                    public Object apply(DbColumnConstraint input) {
                        return input.translate();
                    }
                });

        sb.append(Joiner.on(" ").join(trans));
    }

    return sb.toString();
}

From source file:org.sonar.server.user.ws.IdentityProvidersAction.java

private IdentityProvidersWsResponse buildResponse() {
    IdentityProvidersWsResponse.Builder response = IdentityProvidersWsResponse.newBuilder();
    response.addAllIdentityProviders(Lists.transform(identityProviderRepository.getAllEnabledAndSorted(),
            IdentityProviderToWsResponse.INSTANCE));
    return response.build();
}

From source file:org.onosproject.store.service.MapTransaction.java

/**
 * Maps this instance to another {@code MapTransaction} with different key and value types.
 *
 * @param keyMapper function for mapping key types
 * @param valueMapper function for mapping value types
 * @return newly typed instance/* w w  w .j a v a2s.  c  om*/
 *
 * @param <S> key type of returned instance
 * @param <T> value type of returned instance
 */
public <S, T> MapTransaction<S, T> map(Function<K, S> keyMapper, Function<V, T> valueMapper) {
    return new MapTransaction<>(transactionId, Lists.transform(updates, u -> u.map(keyMapper, valueMapper)));
}

From source file:org.sonar.batch.repository.user.UserRepositoryLoader.java

/**
 * Not cache friendly. Should not be used if a cache hit is expected.
 *///from  w w  w. j a  va  2 s .c  o m
public Collection<BatchInput.User> load(List<String> userLogins, @Nullable MutableBoolean fromCache) {
    if (userLogins.isEmpty()) {
        return Collections.emptyList();
    }
    InputStream is = loadQuery(Joiner.on(',').join(Lists.transform(userLogins, new UserEncodingFunction())),
            fromCache);

    return parseUsers(is);
}