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.google.jstestdriver.ActionRunner.java
public void runActions() { RunData runData = factory.get();//from w ww . jav a 2 s . c o m logger.info("TestCases {}", runData.getTestCases().size()); if (logger.isDebugEnabled()) { for (JstdTestCase testCase : runData.getTestCases()) { if (testCase.getTests().size() == 1) { logger.debug("{}:\n{}", testCase.getTests().get(0).getDisplayPath(), Lists.transform(testCase.getDependencies(), new Function<FileInfo, String>() { @Override public String apply(FileInfo f) { return f.getDisplayPath() + "\n"; } })); } } } Iterator<Action> iterator = actions.iterator(); stopWatch.start("runActions"); try { while (iterator.hasNext()) { Action action = iterator.next(); stopWatch.start(action.toString()); logger.info("Running {}", action); try { runData = action.run(runData); } finally { logger.info("Finished {}", action); stopWatch.stop(action.toString()); } } } finally { try { stopWatch.stop("runActions"); Writer writer = new StringWriter(); stopWatch.print(writer); writer.flush(); stopWatchLogger.info(writer.toString()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:fm.last.lastfmlive.service.TwitterClient.java
private static List<Tweet> checkForHashTaggedTweets(String hashTag) { log.debug("Searching Twitter for tweets containing #" + hashTag); RestTemplate restTemplate = new RestTemplate(); Map<?, ?> tweets = restTemplate.getForObject(searchUrl + "{hashTag}", Map.class, "#" + hashTag); List<?> results = (List<?>) tweets.get("results"); log.info("Tweets found: {}", results.size()); return Lists.transform(results, ExtractTweet.INSTANCE); }
From source file:org.onos.yangtools.sal.binding.yang.types.UnionDependencySort.java
/** * Sorts union types by mutual dependencies. * //from w w w. j av a 2s.c o m * At the beginning the union types are selected from * <code>typeDefinitions</code> and wrapped to nodes. The nodes are sorted * and then the wrapped payload is extracted. * * @param typeDefinitions * set of type definitions. * @return list of extended type which are sorted by mutual dependencies * @throws IllegalArgumentException * if <code>typeDefinitions</code> equals <code>null</code> */ public List<ExtendedType> sort(final Set<TypeDefinition<?>> typeDefinitions) { if (typeDefinitions == null) { LOGGER.error("Set of Type Definitions cannot be NULL!"); throw new IllegalArgumentException("Set of Type Definitions " + "cannot be NULL!"); } final Set<ExtendedType> extUnionTypes = unionsFromTypeDefinitions(typeDefinitions); final Set<Node> unsorted = unionTypesToNodes(extUnionTypes); final List<Node> sortedNodes = TopologicalSort.sort(unsorted); return Lists.transform(sortedNodes, new Function<Node, ExtendedType>() { @Override public ExtendedType apply(Node input) { return (ExtendedType) (((NodeWrappedType) input).getWrappedType()); } }); }
From source file:com.metamx.druid.input.MapBasedRow.java
@Override public List<String> getDimension(String dimension) { Object dimValue = event.get(dimension); if (dimValue == null) { return Lists.newArrayList(); } else if (dimValue instanceof List) { return Lists.transform((List) dimValue, new Function<Object, String>() { @Override//from w w w. j ava2 s .co m public String apply(@Nullable Object input) { return String.valueOf(input); } }); } else if (dimValue instanceof Object) { return Arrays.asList(String.valueOf(event.get(dimension))); } else { throw new IAE("Unknown dim type[%s]", dimValue.getClass()); } }
From source file:com.google.jstestdriver.model.JstdTestCaseDelta.java
@Override public String toString() { Function<FileInfo, String> fileInfoToPath = new Function<FileInfo, String>() { @Override/* ww w .j a va 2s . c om*/ public String apply(FileInfo in) { return "\n\t\t" + in.getFilePath(); } }; return String.format("JstdTestCaseDelta(\n\tdependencies[%s],\n\ttests[%s],\n\tplugins[%s])", Lists.transform(dependencies, fileInfoToPath), Lists.transform(tests, fileInfoToPath), Lists.transform(plugins, fileInfoToPath)); }
From source file:org.apache.calcite.rel.mutable.MutableMultiRel.java
protected List<MutableRel> cloneChildren() { return Lists.transform(inputs, new Function<MutableRel, MutableRel>() { public MutableRel apply(MutableRel mutableRel) { return mutableRel.clone(); }/*from w ww . j a v a 2s . c o m*/ }); }
From source file:org.raml.jaxrs.generator.v08.V08GResource.java
public V08GResource(final GAbstractionFactory factory, GResource parent, Resource resource, final Set<String> globalSchemas, final V08TypeRegistry registry) { this.factory = factory; this.parent = parent; this.resource = resource; this.registry = registry; this.subResources = Lists.transform(resource.resources(), new Function<Resource, GResource>() { @Nullable/*from w w w . j a v a 2s . co m*/ @Override public GResource apply(@Nullable Resource input) { return factory.newResource(globalSchemas, registry, V08GResource.this, input); } }); this.uriParameters = Lists.transform(resource.uriParameters(), new Function<Parameter, GParameter>() { @Nullable @Override public GParameter apply(@Nullable Parameter input) { return new V08GParameter(input); } }); this.methods = Lists.transform(resource.methods(), new Function<Method, GMethod>() { @Nullable @Override public GMethod apply(@Nullable Method input) { return new V08Method(V08GResource.this, input, globalSchemas, registry); } }); }
From source file:edu.umn.msi.tropix.webgui.server.aop.SanitizingAspect.java
@Around("@annotation(edu.umn.msi.tropix.webgui.aop.SanitizeResults)") public Object sanitizeResults(final ProceedingJoinPoint joinPoint) throws Throwable { final Object toSanitize = joinPoint.proceed(); final Object sanitized; if (toSanitize instanceof ArrayList<?>) { @SuppressWarnings("unchecked") final ArrayList<Object> toSanitizeList = (ArrayList<Object>) toSanitize; final ArrayList<Object> sanitizedList = Lists.newArrayList( Lists.transform(toSanitizeList, BeanSanitizerUtils.<Object>asFunction(beanSanitizer))); sanitized = sanitizedList;//from w w w. ja v a 2 s .c o m } else { sanitized = beanSanitizer.sanitize(toSanitize); } return sanitized; }
From source file:org.summer.dsl.xbase.ui.contentassist.ParameterData.java
public List<String> getRawDisplayString() { sort();/*from w w w . ja v a 2 s . c om*/ return Lists.transform(variants, new Function<Pair<String, Boolean>, String>() { public String apply(Pair<String, Boolean> input) { return input.getFirst(); } }); }
From source file:org.apache.druid.query.aggregation.cardinality.CardinalityAggregatorFactory.java
private static List<DimensionSpec> makeFieldsFromFieldNames(List<String> fieldNames) { return ImmutableList.copyOf(Lists.transform(fieldNames, new Function<String, DimensionSpec>() { @Override// w w w . j ava2 s. com public DimensionSpec apply(String input) { return new DefaultDimensionSpec(input, input); } })); }