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.marand.thinkmed.medications.converter.VariableComplexMedicationToEhrConverter.java

@Override
protected Collection<Pair<ComplexDoseElementDto, HourMinuteDto>> getDoseElements(
        final VariableComplexTherapyDto therapy) {
    return Lists.transform(therapy.getTimedDoseElements(),
            new Function<TimedComplexDoseElementDto, Pair<ComplexDoseElementDto, HourMinuteDto>>() {
                @Nullable//from  w  w w . j  a  v a  2  s .  co m
                @Override
                public Pair<ComplexDoseElementDto, HourMinuteDto> apply(
                        @Nullable final TimedComplexDoseElementDto from) {
                    if (from == null) {
                        return null;
                    }
                    return Pair.of(from.getDoseElement(), from.getDoseTime());
                }
            });
}

From source file:org.codehaus.httpcache4j.preference.Preference.java

public static <T> List<Preference<T>> wrap(T... values) {
    return Lists.transform(Arrays.asList(values), new Function<T, Preference<T>>() {
        @Override/*  w  w w  .j  av a  2 s.  c o m*/
        public Preference<T> apply(T input) {
            return new Preference<T>(input);
        }
    });
}

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

@Override
public List<Integer> accountValues(final String clasId) {
    final BoundHashOperations<String, Object, Object> ops = redisTemplate.boundHashOps(clasId);
    final List<Object> values = ops.values();
    return Lists.transform(values, new Function<Object, Integer>() {

        @Override/*from   w w w  .  ja  v  a2  s . c  o m*/
        public Integer apply(final Object input) {
            return Integer.parseInt((String) input);
        }
    });
}

From source file:models.web.ModuleModel.java

public ModuleModel(Module module) {
    super(module);

    if (module != null) {
        this.id = UuidUtils.normalize(module.getId());
        this.baseName = module.getBaseDisplayName();
        this.name = module.getDisplayName();
        this.url = module.getRoute();
        this.canPartiallyRender = module.canPartiallyRender();
        this.allowSelfOutput = module.allowSelfOutput();
        this.relevancyScore = 1.0;

        if (module.getSubModules() != null) {
            this.subModules = Lists.transform(
                    Lists.newArrayList(Iterables.filter(module.getSubModules(), Predicates.notNull())),
                    new Function<Module, ModuleModel>() {
                        @Override
                        @Nullable//w w w. j  a  v a2 s  .  c  om
                        public ModuleModel apply(@Nullable Module input) {
                            return new ModuleModel(input);
                        }
                    });
        }
    }
}

From source file:net.sourceforge.ganttproject.gui.RecentColorsOption.java

@Override
public String getPersistentValue() {
    if (myColors.isEmpty()) {
        return null;
    }/* w w w .  ja v a2 s . com*/
    List<String> values = Lists.transform(myColors, new Function<Color, String>() {
        @Override
        public String apply(Color c) {
            return Util.getColor(c);
        }
    });
    return Joiner.on(' ').join(values);
}

From source file:org.apache.distributedlog.protocol.util.TwitterFutureUtils.java

public static <T> Future<List<Future<T>>> newTFutureList(
        CompletableFuture<List<CompletableFuture<T>>> jFutureList) {
    Promise<List<Future<T>>> promise = new Promise<>();
    jFutureList.whenComplete((value, cause) -> {
        if (null != cause) {
            if (cause instanceof CompletionException) {
                promise.setException(cause.getCause());
            } else {
                promise.setException(cause);
            }// w w  w.  j  ava 2 s.c o  m
        } else {
            promise.setValue(Lists.transform(value, future -> newTFuture(future)));
        }
    });
    return promise;
}

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

public Collection<ScannerInput.User> load(List<String> userLogins) {
    if (userLogins.isEmpty()) {
        return Collections.emptyList();
    }//from   w w w . j  a va 2  s.c o  m
    InputStream is = loadQuery(Joiner.on(',').join(Lists.transform(userLogins, new UserEncodingFunction())));

    return parseUsers(is);
}

From source file:org.eigenbase.sql.validate.SqlUserDefinedAggFunction.java

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);
        }//w w  w.j  a  v a 2s  .co  m
    });
}

From source file:jflowmap.FlowMapGraphSet.java

public List<FlowMapGraph> asList() {
    return Lists.transform(graphs, FlowMapGraph.funcGraphToFlowMapGraph(attrSpec, stats));
}

From source file:org.gradle.performance.results.CrossBuildPerformanceTestHistory.java

@Override
public List<PerformanceTestExecution> getExecutions() {
    return Lists.transform(newestFirst, new Function<CrossBuildPerformanceResults, PerformanceTestExecution>() {
        public PerformanceTestExecution apply(@Nullable final CrossBuildPerformanceResults results) {
            return new KnownBuildSpecificationsPerformanceTestExecution(results);
        }/*from   w w w.  ja va2  s  .  c  o  m*/
    });
}