List of usage examples for com.google.common.collect Lists newLinkedList
@GwtCompatible(serializable = true) public static <E> LinkedList<E> newLinkedList()
From source file:com.google.sites.liberation.util.EntryProviderImpl.java
@SuppressWarnings("unchecked") @Override/* ww w .j av a2 s. co m*/ public List<BaseContentEntry<?>> getEntries(Query query, SitesService sitesService) throws IOException, ServiceException { checkNotNull(query, "query"); checkNotNull(sitesService, "sitesService"); List<BaseContentEntry> baseEntries = sitesService.getFeed(query, ContentFeed.class).getEntries(); List<BaseContentEntry<?>> adaptedEntries = Lists.newLinkedList(); for (BaseContentEntry entry : baseEntries) { BaseContentEntry<?> adaptedEntry = (BaseContentEntry<?>) entry.getAdaptedEntry(); if (adaptedEntry == null) { adaptedEntries.add(entry); } else { adaptedEntries.add(adaptedEntry); } } return adaptedEntries; }
From source file:us.physion.ovation.ui.importer.ImageImporter.java
public static Observable<Measurement> importImageMeasurements(Epoch epoch, Iterable<File> files) { List<FileMetadata> metadata = Lists.newArrayList(); for (File f : files) { metadata.add(new FileMetadata(f)); }//from w w w. j av a 2 s . com List<Measurement> result = Lists.newLinkedList(); for (FileMetadata fileMetadata : metadata) { for (Map.Entry<String, Object> e : fileMetadata.getEpochProtocolParameters().entrySet()) { epoch.addProtocolParameter(e.getKey(), e.getValue()); } for (Map.Entry<String, Object> e : fileMetadata.getDeviceParameters().entrySet()) { epoch.addDeviceParameter(e.getKey(), e.getValue()); } for (Map<String, Object> m : fileMetadata.getMeasurements()) { try { result.add(epoch.insertMeasurement( String.format("Image %d", (Integer) m.get(FileMetadata.IMAGE_NUMBER)), Sets.<String>newHashSet(), Sets.<String>newHashSet(), new URL((String) m.get(FileMetadata.IMAGE_URL)), (String) m.get(FileMetadata.MIME_TYPE))); } catch (MalformedURLException ex) { throw new OvationException(ex); } } } return Observable.from(result); }
From source file:com.facebook.buck.graph.AbstractBottomUpTraversal.java
public AbstractBottomUpTraversal(TraversableGraph<T> graph) { this.graph = Preconditions.checkNotNull(graph); this.visitedNodes = Sets.newHashSet(); this.nodesToExplore = Lists.newLinkedList(); this.effectiveOutDegreesOfExplorableNodes = Maps.newHashMap(); }
From source file:org.openqa.selenium.remote.server.testing.HeaderContainer.java
protected HeaderContainer() { Map<String, Collection<String>> headersMap = Maps.newHashMap(); this.headers = Multimaps.newListMultimap(headersMap, new Supplier<List<String>>() { public List<String> get() { return Lists.newLinkedList(); }/*from www. j a va2s . c o m*/ }); }
From source file:org.richfaces.demo.iteration.model.tree.adaptors.Entry.java
public String getPath() { List<Entry> entries = Lists.newLinkedList(); Entry entry = this; while (entry != null) { entries.add(0, entry);/* www .j av a 2 s. c o m*/ entry = entry.getParent(); } return Joiner.on(" -> ").join(entries); }
From source file:org.apache.helix.task.TaskStateModelFactory.java
public TaskStateModelFactory(HelixManager manager, Map<String, TaskFactory> taskFactoryRegistry) { _manager = manager;/* ww w. j av a2 s . c o m*/ _taskFactoryRegistry = ImmutableMap.copyOf(taskFactoryRegistry); _taskStateModels = Lists.newLinkedList(); }
From source file:com.google.jstestdriver.BrowserActionRunner.java
public ResponseStream call() { final List<ResponseStream> responseStreams = Lists.newLinkedList(); for (BrowserAction action : actions) { stopWatch.start("run %s", action); logger.debug("Running BrowserAction {}", action); responseStreams.add(action.run(id, client)); stopWatch.stop("run %s", action); }//from www . j ava2 s .com return new AggregatingResponseStream(responseStreams); }
From source file:de.cau.cs.kieler.klay.layered.JsonDebugUtil.java
/** * Output a representation of the given graph in JSON format. * * @param lgraph/* w w w. j a va2 s .co m*/ * the layered graph * @param slotIndex * the slot before whose execution the graph is written. * @param name * the name the slot before whose execution the graph is written. */ public static void writeDebugGraph(final LGraph lgraph, final int slotIndex, final String name) { try { final ConsoleWriter ConsoleWriter = createConsoleWriter(lgraph, slotIndex, name); final List<LEdge> edges = Lists.newLinkedList(); beginGraph(ConsoleWriter, lgraph); // Write layerless nodes and collect edges edges.addAll(writeLayer(ConsoleWriter, -1, lgraph.getLayerlessNodes(), 2)); // Go through the layers int layerNumber = -1; final Iterator<Layer> layersIterator = lgraph.iterator(); if (!lgraph.getLayerlessNodes().isEmpty() && layersIterator.hasNext()) { ConsoleWriter.write(","); } while (layersIterator.hasNext()) { final Layer layer = layersIterator.next(); layerNumber++; // Write the nodes and collect edges edges.addAll(writeLayer(ConsoleWriter, layerNumber, layer.getNodes(), 2)); if (layersIterator.hasNext()) { ConsoleWriter.write(","); } } endChildNodeList(ConsoleWriter); writeEdges(ConsoleWriter, edges, 1); // Close the graph and the ConsoleWriter. endGraph(ConsoleWriter); } catch (final IOException exception) { exception.printStackTrace(); } }
From source file:com.github.talberto.easybeans.atg.RepositoryBeansExtractor.java
public List<MetaBean> extractBeans(Repository pRepo, List<String> pBeanNames) { mLog.info("Extracting beans [{}] from repository [{}]", Joiner.on(",").join(pBeanNames), pRepo.toString()); List<MetaBean> extractedBeans = Lists.newLinkedList(); for (String beanName : pBeanNames) { try {//from w w w .j av a 2 s. c o m RepositoryItemDescriptor descriptor = pRepo.getItemDescriptor(beanName); if (descriptor == null) { throw new IllegalArgumentException( String.format("Doesn't exist an item descriptor named [%s]", beanName)); } List<MetaProperty> properties = extractProperties(descriptor); extractedBeans.add(new MetaBean(beanName, properties)); } catch (RepositoryException e) { throw new MappingException(e); } } return extractedBeans; }
From source file:com.eucalyptus.loadbalancing.activities.EventHandlerChain.java
public void execute(T evt) throws EventHandlerChainException { LinkedList<EventHandler<T>> reverseHandler = Lists.newLinkedList(); for (EventHandler<T> handler : this.handlers) { try {//from w w w . j a v a 2 s . co m reverseHandler.addFirst(handler); // failed handler will rollback too handler.apply(evt); if (handler.skipRemaining()) { LOG.info("skipping the remaining handlers"); break; } } catch (Exception e) { LOG.warn("starting to rollback"); final String msg = e.getMessage() != null ? e.getMessage() : String.format("failed handling %s at %s", evt, handler); final EventHandlerChainException toThrow = new EventHandlerChainException(msg, e, true); for (EventHandler<T> h : reverseHandler) { try { h.rollback(); } catch (Exception ex) { LOG.warn("rollback failed at " + h.toString(), ex); toThrow.setRollback(false); // fail once, rollback status is set to false } } LOG.info("finished rollback"); throw toThrow; } } }