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:de.flapdoodle.mongoom.mapping.reflection.ClassMateResolvedType.java

@Override
public List<IResolvedType> typeParametersFor(Class<?> clazz) {
    return Lists.transform(_type.typeParametersFor(clazz), new Function<ResolvedType, IResolvedType>() {
        @Override/*from w  ww  . j av  a2 s .  c om*/
        public IResolvedType apply(ResolvedType input) {
            return new ClassMateResolvedType(_resolver, input);
        }
    });
}

From source file:org.apache.druid.query.materializedview.MaterializedViewQueryRunner.java

@Override
public Sequence<T> run(QueryPlus<T> queryPlus, Map<String, Object> responseContext) {
    Query query = queryPlus.getQuery();
    return new MergeSequence<>(query.getResultOrdering(),
            Sequences.simple(Lists.transform(optimizer.optimize(query), new Function<Query, Sequence<T>>() {
                @Override/*  www .ja  v  a2  s .  c  o  m*/
                public Sequence<T> apply(Query query) {
                    return runner.run(queryPlus.withQuery(query), responseContext);
                }
            })));
}

From source file:com.github.raymanrt.orientqb.util.Commons.java

public static String joinStrings(String... strings) {
    List<String> tokens = newArrayList(strings);
    tokens = Lists.transform(tokens, singleQuoteFunction);
    return listJoiner.join(tokens);
}

From source file:com.b2international.commons.VersionNumberComparator.java

/**
 * @throws IllegalArgumentException if either of the arguments are not in the expected format
 * @see Comparator#compare(Object, Object)
 *///from ww  w. ja v a2  s  .  c  o  m
@Override
public int compare(String version1, String version2) {
    checkArgument(checkVersionFormat(version1), "Version string format is invalid: " + version1);
    checkArgument(checkVersionFormat(version2), "Version string format is invalid: " + version2);
    List<Integer> version1Parts = Lists.transform(ImmutableList.copyOf(Splitter.on('.').split(version1)),
            new StringToIntegerParserFunction());
    List<Integer> version2Parts = Lists.transform(ImmutableList.copyOf(Splitter.on('.').split(version2)),
            new StringToIntegerParserFunction());
    int minLength = Math.min(version1Parts.size(), version2Parts.size());
    int maxLength = Math.max(version1Parts.size(), version2Parts.size());

    int i = 0;
    for (; i < minLength; i++) {
        Integer integer1 = version1Parts.get(i);
        Integer integer2 = version2Parts.get(i);
        int compareResult = integer1.compareTo(integer2);
        if (compareResult != 0) {
            return compareResult;
        }
    }

    if (minLength != maxLength) {
        return Ints.compare(version1Parts.size(), version2Parts.size());
    } else {
        return 0;
    }
}

From source file:au.id.hazelwood.sos.service.user.impl.UserServiceImpl.java

@Override
public List<UserDto> findAllUsers() {
    return Lists.newArrayList(Lists.transform(userRepository.findAll(), userToUserDtoFunction));
}

From source file:org.jboss.arquillian.graphene.angular.ftest.pageobjects.TodoList.java

public List<TodoItem> openTasks() {
    final List<WebElement> currentTodos = driver.findElements(ByAngular.repeat("todo in todos"));
    return Lists.transform(currentTodos, new Function<WebElement, TodoItem>() {
        @Override/* www.j  a v a2 s  .co  m*/
        public TodoItem apply(WebElement input) {
            final WebElement checkbox = input.findElement(By.tagName("input"));
            final WebElement description = input.findElement(By.tagName("span"));
            return new TodoItem(description.getText(), checkbox.isSelected());
        }
    });
}

From source file:org.apache.kylin.invertedindex.index.SliceBuilder.java

public Slice buildSlice(StreamingBatch microStreamBatch) throws IOException {
    final List<List<String>> messages = Lists.transform(microStreamBatch.getMessages(),
            new Function<StreamingMessage, List<String>>() {
                @Nullable/*  w  w w .  j  av a 2  s.c  om*/
                @Override
                public List<String> apply(@Nullable StreamingMessage input) {
                    return input.getData();
                }
            });
    final Dictionary<?>[] dictionaries = IIDictionaryBuilder.buildDictionary(messages, iiDesc);
    TableRecordInfo tableRecordInfo = new TableRecordInfo(iiDesc, dictionaries);
    return build(messages, tableRecordInfo, dictionaries);
}

From source file:org.nmdp.service.epitope.group.DbiGroupResolver.java

@Override
public List<Allele> apply(final Integer group) {
    List<String> alleleStringList = dbiManager.getAllelesForGroup(group);
    List<Allele> alleleList = Lists.transform(alleleStringList, new Function<String, Allele>() {
        @Override/*from  w  w w.  jav  a2s .c  om*/
        public Allele apply(String name) {
            try {
                return glClient.createAllele(name);
            } catch (GlClientException e) {
                throw new RuntimeException("failed to resolve allele: " + name, e);
            }
        }
    });
    return alleleList;
}

From source file:net.seedboxer.web.service.AdminService.java

public List<RssFeedInfo> getAllRSSFeeds() {
    return Lists.transform(feedsManager.getAllFeeds(), new Function<RssFeed, RssFeedInfo>() {

        @Override/*w ww .  j a va2 s .c  om*/
        @Nullable
        public RssFeedInfo apply(@Nullable RssFeed rss) {
            return (RssFeedInfo) mapper.map(rss);
        }
    });
}

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

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