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:com.ansorgit.plugins.bash.util.VfsCompletionUtil.java

public static List<String> relativePathCompletion(PsiDirectory base, String shownBase, String relativePrefix) {
    String parentDirName = "";
    String fileName = "";

    //split the path
    int lastSlashPos = relativePrefix.lastIndexOf('/');
    if (lastSlashPos == -1) {
        fileName = relativePrefix;/*from www.jav  a  2 s .c  o  m*/
    } else if (lastSlashPos < relativePrefix.length() - 1) {
        parentDirName = relativePrefix.substring(0, lastSlashPos);
        fileName = relativePrefix.substring(lastSlashPos + 1);
    } else {
        parentDirName = relativePrefix;
    }

    PsiDirectory parent = dirInSubtree(base, parentDirName);
    if (parent == null) {
        return Collections.emptyList();
    }

    List<PsiFile> psiFiles = matchingFiles(parent, fileName);
    String commonPrefix = base.getVirtualFile().getPath();

    List<String> result = Lists.newLinkedList();

    for (PsiFile f : psiFiles) {
        VirtualFile file = f.getVirtualFile();
        if (file == null) {
            continue;
        }

        String fullPath = file.getPath();
        if (fullPath.startsWith(commonPrefix)) {
            result.add("." + fullPath.substring(commonPrefix.length()));
        }
    }

    return result;
}

From source file:org.robobinding.binder.BindingAttributeMappingsProviderResolver.java

@SuppressWarnings({ "unchecked" })
public Iterable<BindingAttributeMappingsProvider<? extends View>> findCandidateProviders(View view) {
    Queue<BindingAttributeMappingsProvider<? extends View>> candidateProviders = Lists.newLinkedList();

    if (CustomViewUtils.isCustomWidget(view)) {
        candidateProviders.add(new CustomBindingAttributeMapperAdapter<View>((BindableView<View>) view,
                propertyAttributeParser));
    }//from w w w .ja va 2 s. co m

    processViewHierarchy(view.getClass(), candidateProviders);
    return candidateProviders;
}

From source file:edu.umn.msi.tropix.jobs.activities.factories.GalaxySupportImpl.java

public List<GalaxyInputFile> prepareInputFiles(final Tool tool, final RootInput rootInput,
        final Credential credential) {
    final List<GalaxyInputFile> files = Lists.newLinkedList();
    GalaxyDataUtils.visitParams(tool, rootInput, new ParamVisitor() {
        public void visit(final String key, final Input fileInput, final Param param) {
            final ParamType paramType = param.getType();
            if (paramType != ParamType.DATA) {
                return;
            }/*w ww .j  av a2s . c o  m*/
            final String fileId = fileInput.getValue();
            final ModelStorageData data = persistentModelStorageDataFactory.getPersistedStorageData(fileId,
                    credential);
            final String fileName = data.getTropixFile().getName();
            fileInput.setValue(fileName);
            final GalaxyInputFile fileSummary = new GalaxyInputFile(fileName, data.prepareDownloadResource());
            files.add(fileSummary);
        }
    });
    return files;
}

From source file:com.textocat.textokit.segmentation.heur.OneSentencePerLineSplitter.java

@Override
public void process(JCas cas) throws AnalysisEngineProcessException {
    Deque<Token> sentTokens = Lists.newLinkedList();
    for (TokenBase tb : JCasUtil.select(cas, TokenBase.class)) {
        if (tb instanceof BREAK) {
            if (sentTokens.isEmpty()) {
                continue;
            }//from  w w w.ja  v a 2  s  . com
            makeSentence(cas, sentTokens.getFirst(), sentTokens.getLast());
            sentTokens.clear();
        } else if (tb instanceof Token) {
            sentTokens.add((Token) tb);
        }
    }
    // make last sentence if any tokens are left
    if (!sentTokens.isEmpty()) {
        makeSentence(cas, sentTokens.getFirst(), sentTokens.getLast());
    }
}

From source file:com.griddynamics.jagger.monitoring.reporting.MonitoringReporter.java

@Override
public JRDataSource getDataSource() {
    String sessionId = getSessionIdProvider().getSessionId();
    @SuppressWarnings("unchecked")
    List<PerformedMonitoring> source = getHibernateTemplate().find(
            "select pm from PerformedMonitoring pm " + "where pm.sessionId=? and pm.parentId is null",
            sessionId);//from w w  w. j  a v a2 s . c  o m

    List<MonitoringInfo> result = Lists.newLinkedList();

    for (PerformedMonitoring performedMonitoring : source) {
        MonitoringInfo info = new MonitoringInfo();
        info.setTaskId(performedMonitoring.getMonitoringId());
        info.setTitle(performedMonitoring.getName() + ", " + performedMonitoring.getTermination());
        result.add(info);
    }

    return new JRBeanCollectionDataSource(result);
}

From source file:org.sonar.plugins.switchoffviolations.pattern.PatternDecoder.java

public List<Pattern> decode(File file) {
    try {//from w w  w  .j  a  v  a 2  s. c o  m
        List<String> lines = FileUtils.readLines(file);
        List<Pattern> patterns = Lists.newLinkedList();
        for (String line : lines) {
            Pattern pattern = decodeLine(line);
            if (pattern != null) {
                patterns.add(pattern);
            }
        }
        return patterns;

    } catch (IOException e) {
        throw new SonarException("Fail to load the file: " + file.getAbsolutePath(), e);
    }
}

From source file:net.scriptability.core.configuration.Configuration.java

/**
 * Visits all configuration items with a visit.
 *
 * @param visitor the visitor//from  w  w  w. j  a  v a2  s .  co  m
 * @throws VisitorException if an error occurs during a visit.
 */
public void visit(final Visitor visitor) throws VisitorException {
    final List<Visited> allConfiguration = Lists.newLinkedList();
    allConfiguration.addAll(events.values());
    allConfiguration.addAll(scripts.values());
    allConfiguration.addAll(templates.values());

    for (Visited visited : allConfiguration) {
        visited.accept(visitor);
    }
}

From source file:exec.validate_evaluation.microcommits.FinalStateMicroCommitGenerationRunner.java

private List<MicroCommit> createCommits(List<Usage> qh) {

    List<MicroCommit> commits = Lists.newLinkedList();

    int lastIdx = qh.size() - 1;
    Usage finalState = qh.get(lastIdx);//from  w  w  w . j  a  va  2  s.  co m

    for (int i = 0; i < lastIdx; i++) {
        Usage query = qh.get(i);
        commits.add(MicroCommit.create(query, finalState));
    }

    return commits;
}

From source file:io.brooklyn.entity.nosql.etcd.EtcdProxySshDriver.java

@Override
public void launch() {
    DynamicTasks/*from w  w  w.j  a v  a2s  .  c  o m*/
            .queueIfPossible(
                    DependentConfiguration.attributeWhenReady(entity, EtcdNode.ETCD_NODE_HAS_JOINED_CLUSTER))
            .orSubmitAndBlock(entity).andWaitForSuccess();

    String nodes = String.format("%s=%s", getClusterName(), getClusterUrl());

    // Build etcd startup command
    List<String> commands = Lists.newLinkedList();
    commands.add("cd " + getRunDir());
    commands.add(format("%s -bind-addr 0.0.0.0:%d --proxy on --initial-cluster \"%s\" > %s 2>&1 < /dev/null &",
            Os.mergePathsUnix(getExpandedInstallDir(), "etcd"),
            getEntity().sensors().get(EtcdNode.ETCD_CLIENT_PORT), nodes, getLogFileLocation()));

    newScript(ImmutableMap.of(USE_PID_FILE, true), LAUNCHING).body.append(commands).failOnNonZeroResultCode()
            .execute();
}

From source file:org.summer.ss.core.validation.ValidatingRichStringAcceptor.java

public ValidatingRichStringAcceptor(ValidationMessageAcceptor acceptor) {
    this.acceptor = acceptor;
    this.indentationStack = Lists.newLinkedList();
}