下面列出了com.google.common.collect.ImmutableList.Builder#addAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* @see org.alfasoftware.morf.jdbc.SqlDialect#addTableFromStatements(org.alfasoftware.morf.metadata.Table, org.alfasoftware.morf.sql.SelectStatement)
*/
@Override
public Collection<String> addTableFromStatements(Table table, SelectStatement selectStatement) {
Builder<String> result = ImmutableList.<String>builder();
result.add(new StringBuilder()
.append(createTableStatement(table, true))
.append(" AS ")
.append(convertStatementToSQL(selectStatement))
.toString()
);
result.add("ALTER TABLE " + schemaNamePrefix() + table.getName() + " NOPARALLEL LOGGING");
if (!primaryKeysForTable(table).isEmpty()) {
result.add("ALTER INDEX " + schemaNamePrefix() + primaryKeyConstraintName(table.getName()) + " NOPARALLEL LOGGING");
}
result.addAll(buildRemainingStatementsAndComments(table));
return result.build();
}
private static Collection<SearchMapping> collectMappings(final Map<String, SearchMappings> searchMappings) {
final Builder<SearchMapping> builder = ImmutableList.builder();
// put the default mappings in first
final SearchMappings defaultMappings = searchMappings.get(DEFAULT);
if (defaultMappings != null) {
builder.addAll(defaultMappings.get());
}
// add the rest of the mappings
searchMappings.keySet().stream()
.filter(key -> !DEFAULT.equals(key))
.sorted()
.forEach(key -> builder.addAll(searchMappings.get(key).get()));
return builder.build();
}
private LocalArmeriaPortsElement(Member member, @Nullable PropertyDescriptor pd) {
super(member, pd);
Server server = getServer();
if (server == null) {
server = beanFactory.getBean(Server.class);
serServer(server);
}
final Builder<Integer> ports = ImmutableList.builder();
if (portsCache.isEmpty()) {
synchronized (portsCache) {
if (portsCache.isEmpty()) {
ports.addAll(server.activePorts().values().stream()
.map(p -> p.localAddress().getPort())
.collect(toImmutableList()));
portsCache.addAll(ports.build());
} else {
ports.addAll(portsCache);
}
}
} else {
ports.addAll(portsCache);
}
this.ports = ports.build();
}
@Override
public ImmutableList<Profile> findAllByName(Iterable<String> names) throws IOException, InterruptedException {
CompletionService<List<Profile>> completion = new ExecutorCompletionService<>(executorService);
int count = 0;
for (final List<String> partition : Iterables.partition(names, getEffectiveProfilesPerJob())) {
count++;
completion.submit(() -> resolver.findAllByName(partition));
}
Builder<Profile> builder = ImmutableList.builder();
for (int i = 0; i < count; i++) {
try {
builder.addAll(completion.take().get());
} catch (ExecutionException e) {
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
} else {
throw new RuntimeException("Error occurred during the operation", e);
}
}
}
return builder.build();
}
/**
* Same as {@link #getAttributePath(String, EntityType)} but adds an id attribute to the path is
* the last element is a reference attribute.
*
* @param queryRuleField query rule field name, e.g. grandparent.parent.child
* @param entityType entity type
* @param expandLabelInsteadOfId expand with label attribute instead of id attribute
* @return attribute path
* @throws UnknownAttributeException if no attribute exists for a query rule field name part
* @throws MolgenisQueryException if query rule field is an invalid attribute path
*/
public static List<Attribute> getAttributePathExpanded(
String queryRuleField, EntityType entityType, boolean expandLabelInsteadOfId) {
List<Attribute> attributePath = getAttributePath(queryRuleField, entityType);
List<Attribute> expandedAttributePath;
Attribute attribute = attributePath.get(attributePath.size() - 1);
if (attribute.hasRefEntity()) {
Attribute expandedAttribute;
if (expandLabelInsteadOfId) {
expandedAttribute = attribute.getRefEntity().getLabelAttribute();
} else {
expandedAttribute = attribute.getRefEntity().getIdAttribute();
}
@SuppressWarnings("UnstableApiUsage")
Builder<Attribute> builder = ImmutableList.builderWithExpectedSize(attributePath.size() + 1);
builder.addAll(attributePath);
builder.add(expandedAttribute);
expandedAttributePath = builder.build();
} else {
expandedAttributePath = attributePath;
}
return expandedAttributePath;
}
@Override
public ImmutableList<? extends Step> getBuildSteps(
BuildContext context, BuildableContext buildableContext) {
Builder<Step> builder = ImmutableList.builder();
buildableContext.recordArtifact(extractedOutput);
builder.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), getProjectFilesystem(), extractedOutput)));
builder.add(
new UnzipStep(
getProjectFilesystem(),
context.getSourcePathResolver().getAbsolutePath(binarySrc),
extractedOutput,
Optional.empty()));
builder.add(new MovePythonWhlDataStep(getProjectFilesystem(), extractedOutput));
return builder.build();
}
/**
* When deploying a table need to ensure that an index doesn't already exist when creating it.
* @see org.alfasoftware.morf.jdbc.SqlDialect#tableDeploymentStatements(org.alfasoftware.morf.metadata.Table)
*/
@Override
public Collection<String> tableDeploymentStatements(Table table) {
Builder<String> statements = ImmutableList.<String>builder();
statements.addAll(internalTableDeploymentStatements(table));
for (Index index : table.indexes()) {
statements.add(optionalDropIndexStatement(table, index));
statements.addAll(indexDeploymentStatements(table, index));
}
return statements.build();
}
/**
* Creates SQL to deploy a database table and its associated indexes.
*
* @param table The meta data for the table to deploy.
* @return The statements required to deploy the table and its indexes.
*/
public Collection<String> tableDeploymentStatements(Table table) {
Builder<String> statements = ImmutableList.<String>builder();
statements.addAll(internalTableDeploymentStatements(table));
for (Index index : table.indexes()) {
statements.addAll(indexDeploymentStatements(table, index));
}
return statements.build();
}
/**
* gets a list of all Achievements
*
* @return list of achievements
*/
public ImmutableList<Achievement> getAchievements() {
Builder<Achievement> builder = ImmutableList.builder();
for (List<Achievement> temp : achievements.values()) {
builder.addAll(temp);
}
return builder.build();
}
private static List<Endpoint> endpointsFromApplications(Applications applications, boolean secureVip) {
final Builder<Endpoint> builder = ImmutableList.builder();
for (Application application : applications.getRegisteredApplications()) {
builder.addAll(endpointsFromApplication(application, secureVip));
}
return builder.build();
}
/**
* Collect mixin containers from platform agents
*/
protected final void getContainersFromAgents(Builder<IContainerHandle> list) {
for (IMixinPlatformServiceAgent agent : this.getServiceAgents()) {
Collection<IContainerHandle> containers = agent.getMixinContainers();
if (containers != null) {
list.addAll(containers);
}
}
}
@Override
public ImmutableList<Profile> findAllByName(Iterable<String> names) throws IOException, InterruptedException {
Builder<Profile> builder = ImmutableList.builder();
for (List<String> partition : Iterables.partition(names, MAX_NAMES_PER_REQUEST)) {
builder.addAll(query(partition));
}
return builder.build();
}
private List<String> prefixId(List<String> path) {
if (path.size() == 2) {
return path;
}
Builder<String> result = ImmutableList.builder();
result.add(getId());
result.addAll(path);
return result.build();
}
protected void addJarSetupSteps(
ProjectFilesystem projectFilesystem,
BuildContext context,
JarParameters jarParameters,
Builder<Step> steps) {
steps.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
projectFilesystem,
jarParameters.getJarPath().getParent())));
}
protected void createCompileToJarStepImpl(
ProjectFilesystem projectFilesystem,
BuildContext context,
BuildTarget target,
CompilerParameters compilerParameters,
ImmutableList<String> postprocessClassesCommands,
@Nullable JarParameters abiJarParameters,
@Nullable JarParameters libraryJarParameters,
/* output params */
Builder<Step> steps,
BuildableContext buildableContext) {
Preconditions.checkArgument(abiJarParameters == null);
Preconditions.checkArgument(
libraryJarParameters != null
&& libraryJarParameters
.getEntriesToJar()
.contains(compilerParameters.getOutputPaths().getClassesDir()));
createCompileStep(
context, projectFilesystem, target, compilerParameters, steps, buildableContext);
steps.addAll(
Lists.newCopyOnWriteArrayList(
addPostprocessClassesCommands(
projectFilesystem,
postprocessClassesCommands,
compilerParameters.getOutputPaths().getClassesDir(),
compilerParameters.getClasspathEntries(),
getBootClasspath(context))));
createJarStep(projectFilesystem, libraryJarParameters, steps);
}
private static void addAnnotationGenFolderStep(
BuildTarget invokingTarget,
ProjectFilesystem filesystem,
Builder<Step> steps,
BuildableContext buildableContext,
BuildContext buildContext) {
Path annotationGenFolder =
CompilerOutputPaths.getAnnotationPath(filesystem, invokingTarget).get();
steps.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
buildContext.getBuildCellRootPath(), filesystem, annotationGenFolder)));
buildableContext.recordArtifact(annotationGenFolder);
}
@Override
public ImmutableList<Step> getBuildSteps(
BuildContext context, BuildableContext buildableContext) {
buildableContext.recordArtifact(output);
Builder<Step> steps =
ImmutableList.<Step>builder()
.add(
MkdirStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
getProjectFilesystem(),
output.getParent())));
FilteredSourceFiles filteredSrcs =
new FilteredSourceFiles(
GoCompile.getSourceFiles(testSources, context),
ImmutableList.of(),
platform,
ImmutableList.of(ListType.GoFiles, ListType.TestGoFiles, ListType.XTestGoFiles));
steps.addAll(filteredSrcs.getFilterSteps());
steps.add(
new GoTestMainStep(
getProjectFilesystem().getRootPath(),
testMainGen.getEnvironment(context.getSourcePathResolver()),
testMainGen.getCommandPrefix(context.getSourcePathResolver()),
coverageMode,
coverVariables,
testPackage,
filteredSrcs,
output));
return steps.build();
}
@Override
public Iterable<BuildTarget> getParseTimeDeps(TargetConfiguration targetConfiguration) {
Builder<BuildTarget> deps =
ImmutableList.<BuildTarget>builder()
.addAll(unresolvedCxxPlatform.getParseTimeDeps(targetConfiguration));
deps.addAll(rustCompiler.getParseTimeDeps(targetConfiguration));
linkerOverride.ifPresent(l -> deps.addAll(l.getParseTimeDeps(targetConfiguration)));
return deps.build();
}
/** Gets the steps for preparing the output directories of the build rule. */
public static void getSetupStepsForBuildable(
BuildContext context,
ProjectFilesystem filesystem,
Iterable<Path> outputs,
Builder<Step> stepBuilder,
OutputPathResolver outputPathResolver) {
// TODO(cjhopman): This should probably actually be handled by the build engine.
for (Path output : outputs) {
// Don't delete paths that are invalid now; leave it to the Buildable to handle this.
if (!isValidOutputPath(filesystem, output)) {
continue;
}
// Don't bother deleting the root path or anything under it, we're about to delete it and
// re-create it.
if (!output.startsWith(outputPathResolver.getRootPath())) {
stepBuilder.add(
RmStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), filesystem, output),
true));
}
}
stepBuilder.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), filesystem, outputPathResolver.getRootPath())));
stepBuilder.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(), filesystem, outputPathResolver.getTempPath())));
}
protected void addCompilerSetupSteps(
BuildContext context,
ProjectFilesystem projectFilesystem,
BuildTarget target,
CompilerParameters compilerParameters,
ResourcesParameters resourcesParameters,
Builder<Step> steps) {
// Always create the output directory, even if there are no .java files to compile because there
// might be resources that need to be copied there.
steps.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
projectFilesystem,
compilerParameters.getOutputPaths().getClassesDir())));
steps.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
projectFilesystem,
compilerParameters.getOutputPaths().getAnnotationPath())));
steps.add(
MkdirStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
projectFilesystem,
compilerParameters.getOutputPaths().getOutputJarDirPath())));
// If there are resources, then link them to the appropriate place in the classes directory.
steps.add(
new CopyResourcesStep(
projectFilesystem,
context,
target,
resourcesParameters,
compilerParameters.getOutputPaths().getClassesDir()));
if (!compilerParameters.getSourceFilePaths().isEmpty()) {
steps.add(
MkdirStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
projectFilesystem,
compilerParameters.getOutputPaths().getPathToSourcesList().getParent())));
steps.addAll(
MakeCleanDirectoryStep.of(
BuildCellRelativePath.fromCellRelativePath(
context.getBuildCellRootPath(),
projectFilesystem,
compilerParameters.getOutputPaths().getWorkingDirectory())));
}
}