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();
}
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()));
}
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();
}
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();
}
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();
}
Aggregations