Search in sources :

Example 1 with Builder

use of com.google.common.collect.ImmutableList.Builder in project bazel by bazelbuild.

the class JavaCommon method collectTargetsTreatedAsDeps.

private static ImmutableList<TransitiveInfoCollection> collectTargetsTreatedAsDeps(RuleContext ruleContext, JavaSemantics semantics, ClasspathType type) {
    ImmutableList.Builder<TransitiveInfoCollection> builder = new Builder<>();
    if (!type.equals(ClasspathType.COMPILE_ONLY)) {
        builder.addAll(getRuntimeDeps(ruleContext));
        builder.addAll(getExports(ruleContext));
    }
    builder.addAll(ruleContext.getPrerequisites("deps", Mode.TARGET));
    semantics.collectTargetsTreatedAsDeps(ruleContext, builder);
    // Implicitly add dependency on java launcher cc_binary when --java_launcher= is enabled,
    // or when launcher attribute is specified in a build rule.
    TransitiveInfoCollection launcher = JavaHelper.launcherForTarget(semantics, ruleContext);
    if (launcher != null) {
        builder.add(launcher);
    }
    return builder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder) Builder(com.google.common.collect.ImmutableList.Builder) TransitiveInfoCollection(com.google.devtools.build.lib.analysis.TransitiveInfoCollection)

Example 2 with Builder

use of com.google.common.collect.ImmutableList.Builder in project bazel by bazelbuild.

the class PlistMerging method from.

/**
   * Generates a Plistmerging combining values from sourceFiles and immutableSourceFiles, and
   * modifying them based on substitutions and keysToRemoveIfEmptyString.
   */
public static PlistMerging from(Control control, KeysToRemoveIfEmptyString keysToRemoveIfEmptyString) throws IOException {
    FileSystem fileSystem = FileSystems.getDefault();
    ImmutableList.Builder<Path> sourceFilePathsBuilder = new Builder<>();
    for (String pathString : control.getSourceFileList()) {
        sourceFilePathsBuilder.add(fileSystem.getPath(pathString));
    }
    ImmutableList.Builder<Path> immutableSourceFilePathsBuilder = new Builder<>();
    for (String pathString : control.getImmutableSourceFileList()) {
        immutableSourceFilePathsBuilder.add(fileSystem.getPath(pathString));
    }
    return from(sourceFilePathsBuilder.build(), immutableSourceFilePathsBuilder.build(), control.getVariableSubstitutionMap(), keysToRemoveIfEmptyString, Strings.emptyToNull(control.getExecutableName()));
}
Also used : Path(java.nio.file.Path) ImmutableList(com.google.common.collect.ImmutableList) FileSystem(java.nio.file.FileSystem) Builder(com.google.common.collect.ImmutableList.Builder) NSString(com.dd.plist.NSString)

Example 3 with Builder

use of com.google.common.collect.ImmutableList.Builder in project coprhd-controller by CoprHD.

the class ApiPrimitiveMaker method makeOutput.

/**
 * Make a list of output fields for this primitive
 *
 * @param method
 *            the ApiMethod that is used to generate the primitive
 *
 * @return the list of output fields
 */
private static Iterable<FieldSpec> makeOutput(final ApiMethod method) {
    final ImmutableList.Builder<FieldSpec> builder = ImmutableList.<FieldSpec>builder();
    final ImmutableList.Builder<String> parameters = new ImmutableList.Builder<String>();
    final ParameterFieldName.Output fieldName = new ParameterFieldName.Output();
    if (null != method.output && null != method.output.fields) {
        builder.add(makeStringConstant("RESPONSE", method.getFqReturnType()));
        for (final ApiField field : method.output.fields) {
            final ImmutableList<FieldSpec> responseParameters = makeResponseParameters(fieldName, method.output.name, field);
            for (final FieldSpec responseParameter : responseParameters) {
                parameters.add(responseParameter.name);
            }
            builder.addAll(responseParameters);
        }
    } else {
        builder.add(makeStringConstant("RESPONSE", ""));
    }
    return builder.add(FieldSpec.builder(ParameterizedTypeName.get(List.class, OutputParameter.class), "OUTPUT").addModifiers(Modifier.PRIVATE, Modifier.FINAL, Modifier.STATIC).initializer("new $T().add($L).build()", ParameterizedTypeName.get(ImmutableList.Builder.class, OutputParameter.class), Joiner.on(",").join(parameters.build())).build()).build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) Builder(com.google.common.collect.ImmutableList.Builder) FieldSpec(com.squareup.javapoet.FieldSpec) ApiField(com.emc.apidocs.model.ApiField)

Example 4 with Builder

use of com.google.common.collect.ImmutableList.Builder in project GeoGig by boundlessgeo.

the class HttpUtils method getParents.

/**
     * Gets the parents of the specified commit from the remote repository.
     * 
     * @param repositoryURL the URL of the repository
     * @param commit the id of the commit whose parents to retrieve
     * @return a list of parent ids for the commit
     */
public static ImmutableList<ObjectId> getParents(URL repositoryURL, ObjectId commit) {
    HttpURLConnection connection = null;
    Builder<ObjectId> listBuilder = new ImmutableList.Builder<ObjectId>();
    try {
        String expanded = repositoryURL.toString() + "/repo/getparents?commitId=" + commit.toString();
        connection = connect(expanded);
        // Get Response
        InputStream is = HttpUtils.getResponseStream(connection);
        try {
            BufferedReader rd = new BufferedReader(new InputStreamReader(is));
            String line = rd.readLine();
            while (line != null) {
                listBuilder.add(ObjectId.valueOf(line));
                line = rd.readLine();
            }
        } finally {
            consumeAndCloseStream(is);
        }
    } catch (Exception e) {
        Throwables.propagate(e);
    } finally {
        consumeErrStreamAndCloseConnection(connection);
    }
    return listBuilder.build();
}
Also used : HttpURLConnection(java.net.HttpURLConnection) InputStreamReader(java.io.InputStreamReader) ObjectId(org.locationtech.geogig.api.ObjectId) GZIPInputStream(java.util.zip.GZIPInputStream) FilterInputStream(java.io.FilterInputStream) CountingInputStream(com.google.common.io.CountingInputStream) InputStream(java.io.InputStream) Builder(com.google.common.collect.ImmutableList.Builder) BufferedReader(java.io.BufferedReader) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException)

Example 5 with Builder

use of com.google.common.collect.ImmutableList.Builder in project GeoGig by boundlessgeo.

the class HttpUtils method getAffectedFeatures.

/**
     * Retrieves a list of features that were modified or deleted by a particular commit.
     * 
     * @param repositoryURL the URL of the repository
     * @param commit the id of the commit to check
     * @return a list of features affected by the commit
     */
public static ImmutableList<ObjectId> getAffectedFeatures(URL repositoryURL, ObjectId commit) {
    HttpURLConnection connection = null;
    Builder<ObjectId> listBuilder = new ImmutableList.Builder<ObjectId>();
    try {
        String expanded = repositoryURL.toString() + "/repo/affectedfeatures?commitId=" + commit.toString();
        connection = connect(expanded);
        // Get Response
        InputStream is = HttpUtils.getResponseStream(connection);
        try {
            BufferedReader rd = new BufferedReader(new InputStreamReader(is));
            String line = rd.readLine();
            while (line != null) {
                listBuilder.add(ObjectId.valueOf(line));
                line = rd.readLine();
            }
        } finally {
            consumeAndCloseStream(is);
        }
    } catch (Exception e) {
        Throwables.propagate(e);
    } finally {
        consumeErrStreamAndCloseConnection(connection);
    }
    return listBuilder.build();
}
Also used : HttpURLConnection(java.net.HttpURLConnection) InputStreamReader(java.io.InputStreamReader) ObjectId(org.locationtech.geogig.api.ObjectId) GZIPInputStream(java.util.zip.GZIPInputStream) FilterInputStream(java.io.FilterInputStream) CountingInputStream(com.google.common.io.CountingInputStream) InputStream(java.io.InputStream) Builder(com.google.common.collect.ImmutableList.Builder) BufferedReader(java.io.BufferedReader) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException)

Aggregations

Builder (com.google.common.collect.ImmutableList.Builder)14 ImmutableList (com.google.common.collect.ImmutableList)5 HashSet (java.util.HashSet)3 RelDataType (org.apache.calcite.rel.type.RelDataType)3 RexBuilder (org.apache.calcite.rex.RexBuilder)3 ApiField (com.emc.apidocs.model.ApiField)2 CountingInputStream (com.google.common.io.CountingInputStream)2 FieldSpec (com.squareup.javapoet.FieldSpec)2 BufferedReader (java.io.BufferedReader)2 FilterInputStream (java.io.FilterInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 HttpURLConnection (java.net.HttpURLConnection)2 ArrayList (java.util.ArrayList)2 GZIPInputStream (java.util.zip.GZIPInputStream)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 RelOptCluster (org.apache.calcite.plan.RelOptCluster)2 RelNode (org.apache.calcite.rel.RelNode)2 AggregateCall (org.apache.calcite.rel.core.AggregateCall)2