Example usage for com.google.common.collect Lists newLinkedList

List of usage examples for com.google.common.collect Lists newLinkedList

Introduction

In this page you can find the example usage for com.google.common.collect Lists newLinkedList.

Prototype

@GwtCompatible(serializable = true)
public static <E> LinkedList<E> newLinkedList() 

Source Link

Document

Creates a mutable, empty LinkedList instance (for Java 6 and earlier).

Usage

From source file:uk.ac.ebi.atlas.solr.admin.index.conditions.differential.DifferentialConditionsBuilder.java

public Collection<DifferentialCondition> buildProperties(DifferentialExperiment experiment,
        SetMultimap<String, String> ontologyTermIdsByAssayAccession) {

    Collection<DifferentialCondition> conditions = Lists.newLinkedList();

    Set<Contrast> contrasts = experiment.getContrasts();
    for (Contrast contrast : contrasts) {
        conditions.addAll(buildPropertiesForAssayGroup(experiment, contrast.getId(),
                contrast.getReferenceAssayGroup(), ontologyTermIdsByAssayAccession));
        conditions.addAll(buildPropertiesForAssayGroup(experiment, contrast.getId(),
                contrast.getTestAssayGroup(), ontologyTermIdsByAssayAccession));
    }/*from w  w  w  .j a  v  a2 s. c om*/

    return conditions;
}

From source file:eu.project.ttc.models.scored.ScoredModel.java

public void importTermIndex(TermIndex termIndex) {
    this.terms = Lists.newLinkedList();
    for (Term t : termIndex.getTerms()) {
        List<ScoredVariation> scoredVariations = Lists.newArrayListWithExpectedSize(t.getVariations().size());
        ScoredTerm st = getAdapter(t);//from w  w w. j av a2s . c  o m
        for (TermVariation tv : t.getVariations()) {
            ScoredVariation stv = new ScoredVariation(this, tv);
            scoredVariations.add(stv);
        }
        st.setVariations(scoredVariations);
        this.terms.add(st);
    }
    this.termIndex = termIndex;
}

From source file:org.sonar.core.components.DefaultMetricFinder.java

public Collection<Metric> findAll(List<String> metricKeys) {
    List<Metric> result = Lists.newLinkedList();
    for (String metricKey : metricKeys) {
        Metric metric = findByKey(metricKey);
        if (metric != null) {
            result.add(metric);//from  ww w. j  a  va 2 s .  co  m
        }
    }
    return result;
}

From source file:org.cloudifysource.cosmo.dsl.packaging.DSLPackageProcessor.java

private static List<Path> getFiles(Path path, String pattern, boolean recursive) {
    if (Files.notExists(path)) {
        return Collections.emptyList();
    }// w ww.  j  av a  2s .com
    final List<Path> files = Lists.newLinkedList();
    getFilesImpl(path, pattern, files, recursive);
    return files;
}

From source file:org.apache.tez.analyzer.CSVResult.java

public CSVResult(String[] header) {
    this.headers = header;
    recordsList = Lists.newLinkedList();
}

From source file:bio.pih.genoogle.search.RemoteSimilaritySearcher.java

@Override
public SearchResults call() {
    long begin = System.currentTimeMillis();

    ExecutorService queryExecutor = Executors.newFixedThreadPool(sp.getMaxThreadsIndexSearch());

    List<Throwable> fails = Lists.newLinkedList();
    fails = Collections.synchronizedList(fails);
    final IndexSixFramesSearcher indexSearcher = new IndexSixFramesSearcher(id, sp, databank, queryExecutor,
            fails);/*from  ww  w .  j a v a2s.co  m*/

    IndexSearchResults indexSearchResults = null;
    try {
        indexSearchResults = indexSearcher.call();
    } catch (InterruptedException e) {
        sr.addFail(e);
        return sr;
    }

    queryExecutor.shutdown();

    if (fails.size() > 0) {
        sr.addAllFails(fails);
        return sr;
    }

    logger.info("Index Searcher " + this.toString() + " " + (System.currentTimeMillis() - begin));

    long alignmentBegin = System.currentTimeMillis();

    ExecutorService alignerExecutor = Executors.newFixedThreadPool(sp.getMaxThreadsExtendAlign());

    int maxHits = sp.getMaxHitsResults() > 0 ? sp.getMaxHitsResults() : indexSearchResults.size();
    maxHits = Math.min(maxHits, indexSearchResults.size());

    CountDownLatch alignnmentsCountDown = new CountDownLatch(maxHits);

    try {
        for (int i = 0; i < maxHits; i++) {
            RetrievedSequenceAreas retrievedArea = indexSearchResults.get(i);
            SequenceAligner sequenceAligner = new SequenceAligner(alignnmentsCountDown,
                    indexSearchResults.getIndexSearchers(), retrievedArea, sr, databank, databank.getEncoder(),
                    databank.getAaEncoder(), databank.getReducedEncoder(),
                    // TODO: be possible to set the substitution matrix
                    SubstitutionMatrix.BLOSUM62);
            alignerExecutor.submit(sequenceAligner);
        }
    } catch (IOException e) {
        sr.addFail(e);
        return sr;
    }

    try {
        alignnmentsCountDown.await();
    } catch (InterruptedException e) {
        sr.addFail(e);
        return sr;
    }

    alignerExecutor.shutdown();

    ListIterator<Hit> hitsIterator = sr.getHits().listIterator();
    while (hitsIterator.hasNext()) {
        Hit hit = hitsIterator.next();
        filterHSPs(hit.getHSPs());
        if (hit.getHSPs().isEmpty()) {
            hitsIterator.remove();
        } else {
            Collections.sort(hit.getHSPs(), HSP.COMPARATOR);
        }
    }

    Collections.sort(sr.getHits(), Hit.COMPARATOR);
    logger.info("Alignments total Time of " + this.toString() + " "
            + (System.currentTimeMillis() - alignmentBegin));
    logger.info("Total Time of " + this.toString() + " " + (System.currentTimeMillis() - begin));

    return sr;
}

From source file:com.isotrol.impe3.core.component.BaseInjectors.java

private BaseInjectors(Class<T> type, Iterable<Method> methods) {
    super(type);/*from ww  w  .j a  v  a 2 s  .  c o m*/
    final List<BaseInjector> list = Lists.newLinkedList();
    for (Method method : methods) {
        list.add(new BaseInjector(method));
    }
    this.injectors = ImmutableList.copyOf(list);
}

From source file:com.technostar98.tcbot.bot.BotManager.java

public static void start() {
    synchronized (lock) {
        List<Service> services = Lists.newLinkedList();
        for (final Map.Entry<String, IRCBot> e : bots.entrySet()) {
            Service s = new AbstractExecutionThreadService() {
                IRCBot bot = e.getValue();
                String server = e.getKey();

                @Override//from   w  w w .j  a  va2s  . co  m
                protected void run() throws Exception {
                    Logger.info("Bot for %s server starting up.", server);
                    bot.getBot().startBot();
                }

                @Override
                protected void startUp() throws Exception {
                    super.startUp();
                }

                @Override
                protected void shutDown() throws Exception {
                    super.shutDown();
                    /*System.out.println("Shutting down.");
                    bot.getBot().stopBotReconnect();
                    bot.getBot().sendIRC().quitServer("Adios");
                    getBotOutputPipe(server).messengerPipeline.setOutputEnabled(false);
                    getBotOutputPipe(server).closeListener();
                    try {
                    Thread.sleep(50L);
                    } catch (InterruptedException e1) {
                    e1.printStackTrace();
                    }
                    bot.getBot().getInputParser().close();
                    bots.remove(server);*/
                }

                @Override
                protected void triggerShutdown() {
                    super.triggerShutdown();
                    Logger.info("Bot for server %s is shutting down. Closing all tied resources.", server);

                    try {
                        shutDown();
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                }
            };
            services.add(s);
        }

        manager = new ServiceManager(services);
        manager.addListener(new ServiceManager.Listener() {
            @Override
            public void healthy() {
                super.healthy();
                Logger.info("All bot instances started correctly.");
            }

            @Override
            public void stopped() {
                super.stopped();
                Logger.info("All bots shutdown.");
            }

            @Override
            public void failure(Service service) {
                super.failure(service);
                try {
                    IRCBot bot = (IRCBot) service.getClass().getDeclaredField("bot").get(service);
                    Logger.info("Bot for server %s has failed to start.",
                            bot.getServerConfiguration().getServerName());
                } catch (NoSuchFieldException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        });
        manager.startAsync();

        dataManager = new Thread(() -> {
            while (bots.size() > 0) {
                try {
                    Thread.sleep(600000);
                } catch (InterruptedException e) {
                    //ignore
                }

                bots.keySet().forEach(
                        s -> getBotOutputPipe(s).getChannelManagers().forEach(c -> c.saveChannelData()));
            }
        });
        dataManager.start();
    }
}

From source file:org.apache.streams.rss.processor.RssTypeConverter.java

@Override
public List<StreamsDatum> process(StreamsDatum datum) {
    List<StreamsDatum> datums = Lists.newLinkedList();
    if (datum.getDocument() instanceof ObjectNode) {
        Activity activity = this.serializer.deserialize((ObjectNode) datum.getDocument());
        datums.add(new StreamsDatum(activity, activity.getId(), DateTime.now().withZone(DateTimeZone.UTC)));
        successCount++;/*from  w w w .ja v  a  2  s. c o m*/
    } else {
        failCount++;
        throw new NotImplementedException(
                "Not implemented for class type : " + datum.getDocument().getClass().toString());

    }
    LOGGER.debug("Processor current success count: {} and current fail: {}", successCount, failCount);

    return datums;
}

From source file:com.isotrol.impe3.core.component.PropertyInjectors.java

private PropertyInjectors(Class<T> type, Iterable<Method> methods) {
    super(type);//w  ww  .  j  a  v  a2  s  . c  o m
    final List<PropertyInjector> list = Lists.newLinkedList();
    for (Method method : methods) {
        list.add(new PropertyInjector(method));
    }
    this.injectors = ImmutableList.copyOf(list);
}