Example usage for com.google.common.collect ImmutableList toArray

List of usage examples for com.google.common.collect ImmutableList toArray

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList toArray.

Prototype

<T> T[] toArray(T[] a);

Source Link

Document

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.

Usage

From source file:com.spectralogic.ds3cli.views.cli.GetVersionedBucketView.java

protected String[][] formatTableContents() {

    final ImmutableList.Builder<String[]> builder = ImmutableList.builder();

    for (final Contents content : contents) {
        final String[] arrayEntry = new String[6];
        arrayEntry[0] = nullGuard(content.getKey());
        arrayEntry[1] = nullGuard(Long.toString(content.getSize()));
        arrayEntry[2] = nullGuard(content.getOwner().getDisplayName());
        arrayEntry[3] = nullGuardFromDate(content.getLastModified(), DATE_FORMAT);
        arrayEntry[4] = nullGuard(content.getETag());
        arrayEntry[5] = nullGuard(content.getVersionId());
        builder.add(arrayEntry);/*from ww w  . j a  v a  2s  . com*/
    }

    final ImmutableList<String[]> contentStrings = builder.build();
    return contentStrings.toArray(new String[contentStrings.size()][]);
}

From source file:com.spectralogic.ds3cli.views.cli.GetDataPoliciesView.java

protected String[][] formatTableContents() {

    final ImmutableList.Builder<String[]> builder = ImmutableList.builder();

    for (final DataPolicy dataPolicy : dataPolicies) {
        final String[] arrayEntry = new String[this.columnCount];
        arrayEntry[0] = nullGuardToString(dataPolicy.getName());
        arrayEntry[1] = nullGuardFromDate(dataPolicy.getCreationDate(), DATE_FORMAT);
        arrayEntry[2] = nullGuardToString(dataPolicy.getVersioning());
        arrayEntry[3] = nullGuardToString(dataPolicy.getChecksumType());
        arrayEntry[4] = nullGuardToString(dataPolicy.getEndToEndCrcRequired());
        arrayEntry[5] = nullGuardToString(dataPolicy.getBlobbingEnabled());
        arrayEntry[6] = nullGuardToString(dataPolicy.getDefaultBlobSize());
        arrayEntry[7] = nullGuardToString(dataPolicy.getDefaultGetJobPriority());
        arrayEntry[8] = nullGuardToString(dataPolicy.getDefaultPutJobPriority());
        arrayEntry[9] = nullGuardToString(dataPolicy.getDefaultVerifyJobPriority());
        arrayEntry[10] = nullGuardToString(dataPolicy.getId());
        arrayEntry[11] = nullGuardToString(dataPolicy.getLtfsObjectNamingAllowed());
        builder.add(arrayEntry);//from   www . j  a v  a 2 s  .  co m
    }

    final ImmutableList<String[]> dataPolicyStrings = builder.build();
    return dataPolicyStrings.toArray(new String[dataPolicyStrings.size()][]);
}

From source file:org.apache.atlas.repository.memory.ClassStore.java

ReferenceableInstance createInstance(MemRepository repo, Id id) throws RepositoryException {
    Integer pos = idPosMap.get(id);
    String typeName = typeNameList.get(pos);
    if (!Objects.equals(typeName, hierarchicalType.getName())) {
        return repo.getClassStore(typeName).createInstance(repo, id);
    }//from   www  .  j  av a 2s .  c o  m

    ImmutableList<String> traitNames = traitNamesStore.get(pos);
    String[] tNs = traitNames.toArray(new String[] {});

    try {
        return (ReferenceableInstance) classType.createInstance(id, tNs);
    } catch (AtlasException me) {
        throw new RepositoryException(me);
    }
}

From source file:com.palantir.typescript.search.SearchResultPage.java

@Override
public Match[] getDisplayedMatches(Object element) {
    if (element instanceof LineResult) {
        LineResult lineResult = (LineResult) element;
        ImmutableList<FindReferenceMatch> matches = lineResult.getMatches();

        return matches.toArray(new Match[matches.size()]);
    } else if (element instanceof IResource) {
        SearchResult input = (SearchResult) this.getInput();

        return input.getMatches(element);
    }//from   w w  w .  ja v a 2s. c o m

    return super.getDisplayedMatches(element);
}

From source file:org.eclipse.buildship.ui.view.task.WorkbenchSelectionListener.java

private void selectProjectsInTree(List<IProject> projects) {
    Builder<TreeItem> selection = ImmutableList.builder();

    Tree tree = this.taskView.getTreeViewer().getTree();
    for (TreeItem treeItem : tree.getItems()) {
        Object data = treeItem.getData();
        if (data instanceof BaseProjectNode) {
            BaseProjectNode selectedNode = (BaseProjectNode) data;
            Optional<IProject> workspaceProject = selectedNode.getWorkspaceProject();
            if (workspaceProject.isPresent() && projects.contains(workspaceProject.get())) {
                selection.add(treeItem);
            }//from  w  w  w  . j a va2  s .c o  m
        }
    }

    ImmutableList<TreeItem> treeSelection = selection.build();
    tree.setSelection(treeSelection.toArray(new TreeItem[treeSelection.size()]));
}

From source file:ch.acanda.eclipse.pmd.java.resolution.PMDMarkerResolutionGenerator.java

@Override
public IMarkerResolution[] getResolutions(final IMarker marker) {
    final JavaQuickFixContext context = new JavaQuickFixContext(getCompilerCompliance(marker));
    final ImmutableList<IMarkerResolution> quickFixes = quickFixGenerator
            .getQuickFixes(new WrappingPMDMarker(marker), context);
    return quickFixes.toArray(new IMarkerResolution[quickFixes.size()]);
}

From source file:com.facebook.buck.apple.RegisterDebugSymbolsStep.java

@Override
public StepExecutionResult execute(ExecutionContext context) throws IOException, InterruptedException {
    ImmutableList<String> lldbCommandPrefix = lldb.getCommandPrefix(resolver);
    ProcessExecutorParams params = ProcessExecutorParams.builder()
            .addCommand(lldbCommandPrefix.toArray(new String[lldbCommandPrefix.size()])).build();
    return StepExecutionResult
            .of(context.getProcessExecutor()
                    .launchAndExecute(params, ImmutableSet.of(),
                            Optional.of(String.format("target create %s\ntarget symbols add %s",
                                    resolver.getAbsolutePath(binary), dsymPath)),
                            Optional.empty(), Optional.empty()));
}

From source file:org.openqa.selenium.build.BuckBuild.java

public Path go() throws IOException {
    Path projectRoot = InProject.locate("Rakefile").getParent();

    if (!isInDevMode()) {
        // we should only need to do this when we're in dev mode
        // when running in a test suite, our dependencies should already
        // be listed.
        log.info("Not in dev mode. Ignoring attempt to build: " + target);
        return findOutput(projectRoot);
    }//  w w  w .  ja  va 2 s .c  o m

    if (target == null || "".equals(target)) {
        throw new IllegalStateException("No targets specified");
    }
    System.out.println("\nBuilding " + target + " ...");

    ImmutableList.Builder<String> builder = ImmutableList.builder();
    findBuck(projectRoot, builder);
    builder.add("build", "--config", "color.ui=never", target);

    ImmutableList<String> command = builder.build();
    CommandLine commandLine = new CommandLine(command.toArray(new String[0]));
    commandLine.setWorkingDirectory(projectRoot.toAbsolutePath().toString());
    commandLine.copyOutputTo(System.err);
    commandLine.execute();

    if (!commandLine.isSuccessful()) {
        throw new WebDriverException("Build failed! " + target + "\n" + commandLine.getStdOut());
    }

    return findOutput(projectRoot);
}

From source file:org.eclipse.buildship.ui.console.RemoveAllTerminatedGradleConsolesAction.java

@Override
public void run() {
    ImmutableList<GradleConsole> terminatedConsoles = getTerminatedConsoles();
    ConsolePlugin.getDefault().getConsoleManager()
            .removeConsoles(terminatedConsoles.toArray(new GradleConsole[terminatedConsoles.size()]));
}

From source file:org.openqa.selenium.BuckBuild.java

public Path go() throws IOException {
    Path projectRoot = InProject.locate("Rakefile").toPath().getParent();

    if (!isInDevMode()) {
        // we should only need to do this when we're in dev mode
        // when running in a test suite, our dependencies should already
        // be listed.
        log.info("Not in dev mode. Ignoring attempt to build: " + target);
        return findOutput(projectRoot);
    }/*from  www . j a  v  a2  s . co m*/

    if (target == null || "".equals(target)) {
        throw new IllegalStateException("No targets specified");
    }
    System.out.println("\nBuilding " + target + " ...");

    ImmutableList.Builder<String> builder = ImmutableList.builder();
    findBuck(projectRoot, builder);
    builder.add("build");
    builder.add(target);

    ImmutableList<String> command = builder.build();
    CommandLine commandLine = new CommandLine(command.toArray(new String[command.size()]));
    commandLine.copyOutputTo(System.err);
    commandLine.execute();

    if (!commandLine.isSuccessful()) {
        throw new WebDriverException("Build failed! " + target);
    }

    return findOutput(projectRoot);
}