List of usage examples for com.google.common.collect Lists transform
@CheckReturnValue public static <F, T> List<T> transform(List<F> fromList, Function<? super F, ? extends T> function)
From source file:com.textocat.textokit.commons.cas.AITOverlapIndex.java
AITOverlapIndex(Iterator<A> srcIter) { List<A> srcList = Lists.newArrayList(srcIter); Collections.sort(srcList, offsetComp); List<OffsetsWithValue<A>> intervals = Lists.transform(srcList, new Function<A, OffsetsWithValue<A>>() { @Override//from w w w . j a va 2 s. c o m public OffsetsWithValue<A> apply(A anno) { return new OffsetsWithValue<A>(anno.getBegin(), anno.getEnd(), anno); } }); tree = new ImmutableAugmentedIntervalTree<>(intervals); }
From source file:com.blacklocus.jres.request.search.query.JresDisMaxQuery.java
public JresDisMaxQuery(List<JresQuery> queries) { this.queries = Lists.transform(queries, new Function<JresQuery, Map<String, JresQuery>>() { @Override//from w w w . java 2 s . co m public Map<String, JresQuery> apply(JresQuery input) { return ImmutableMap.of(input.queryType(), input); } }); }
From source file:org.trnltk.tokenizer.TextBlockGroup.java
public TextBlockGroup(List<TextBlock> textBlocks) { this.textBlocks = ImmutableList.copyOf(textBlocks); this.textBlockTypeGroup = new TextBlockTypeGroup( Lists.transform(textBlocks, new Function<TextBlock, TextBlockType>() { @Override//from ww w. j av a 2 s . c om public TextBlockType apply(TextBlock input) { return input.getTextBlockType(); } })); this.firstTextBlock = textBlocks.get(0); }
From source file:io.druid.query.DruidMetrics.java
public static <T> ServiceMetricEvent.Builder makePartialQueryTimeMetric(Query<T> query) { return new ServiceMetricEvent.Builder() .setDimension(DATASOURCE, DataSourceUtil.getMetricName(query.getDataSource())) .setDimension(TYPE, query.getType()) .setDimension(INTERVAL, Lists.transform(query.getIntervals(), new Function<Interval, String>() { @Override//from w w w. j av a2 s . c o m public String apply(Interval input) { return input.toString(); } }).toArray(new String[query.getIntervals().size()])) .setDimension("hasFilters", String.valueOf(query.hasFilters())) .setDimension("duration", query.getDuration().toString()); }
From source file:com.epam.reportportal.utils.LaunchFile.java
public static Maybe<String> find(final String name) { File tempDir = getTempDir();/*from ww w. j a va 2 s . c o m*/ final String prefix = FILE_PREFIX + "-" + normalizeLaunchName(name); List<String> files = Arrays.asList(tempDir.list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith(prefix) && FILENAME_PATTERN.matcher(name).matches(); } })); List<StartLaunchRS> fileRSs = new ArrayList( Lists.transform(files, new com.google.common.base.Function<String, StartLaunchRS>() { @Override public StartLaunchRS apply(String input) { Matcher m = FILENAME_PATTERN.matcher(input); if (m.find()) { return new StartLaunchRS(m.group(3), Long.parseLong(m.group(2))); } throw new RuntimeException("Does not match:" + input); } })); Collections.sort(fileRSs, new Comparator<StartLaunchRS>() { @Override public int compare(StartLaunchRS o1, StartLaunchRS o2) { return -1 * o1.getNumber().compareTo(o2.getNumber()); } }); return Maybe.just(fileRSs.get(0).getId()); }
From source file:bear.plugins.groovy.Replacements.java
Replacements addAll(List<GroovyCodeCompleter.Candidate> candidates) { replacements.addAll(Lists.transform(candidates, new Function<GroovyCodeCompleter.Candidate, Replacement>() { public Replacement apply(GroovyCodeCompleter.Candidate input) { return input.r; }//from w w w . j a v a 2 s . c o m })); return this; }
From source file:org.kududb.client.NoLeaderMasterFoundException.java
/** * Factory method that creates a NoLeaderException given a message and a list * (which may be empty, but must be initialized) of exceptions encountered: they indicate * why {@link GetMasterRegistrationRequest} calls to the masters in the config * have failed, to aid in debugging the issue. If the list is non-empty, each exception's * 'toString()' message is appended to 'msg' and the last exception is used as the * cause for the exception./* w ww . j a va2 s .c o m*/ * @param msg A message detailing why this exception occured. * @param causes List of exceptions encountered when retrieving registration from individual * masters. * @return An instantiated NoLeaderMasterFoundException which can be thrown. */ static NoLeaderMasterFoundException create(String msg, List<Exception> causes) { if (causes.isEmpty()) { return new NoLeaderMasterFoundException(msg); } String joinedMsg = msg + ". Exceptions received: " + Joiner.on(",").join(Lists.transform(causes, Functions.toStringFunction())); return new NoLeaderMasterFoundException(joinedMsg, causes.get(causes.size() - 1)); }
From source file:eu.itesla_project.computation.SimpleCommandImpl.java
@Override public List<String> getArgs(final String executionNumber) { return Lists.transform(args, new Function<String, String>() { @Override/*from w ww .j a v a 2 s.c o m*/ public String apply(String args) { return args.replace(EXECUTION_NUMBER_PATTERN, executionNumber); } }); }
From source file:io.pelle.mango.client.base.modules.hierarchical.BaseHierarchicalConfiguration.java
@SuppressWarnings("rawtypes") protected void addHierarchy(BaseModel baseModel, BaseModel... parentModels) { if (parentModels.length > 0) { List<String> parentDictionaryNames = Lists.transform(Arrays.asList(parentModels), new Function<BaseModel, String>() { @Override//from w w w .j a v a2s . c o m @Nullable public String apply(@Nullable BaseModel input) { return input.getName(); } }); this.hierarchy.put(baseModel.getName(), new ArrayList<String>(parentDictionaryNames)); } else { this.hierarchy.put(baseModel.getName(), Collections.<String>emptyList()); } }
From source file:com.alibaba.otter.node.etl.load.loader.weight.WeightBuckets.java
/** * ?weight??//from w w w. j av a 2 s.co m */ public synchronized List<Long> weights() { return Lists.transform(buckets, new Function<WeightBucket<T>, Long>() { public Long apply(WeightBucket<T> input) { return input.getWeight(); } }); }