本文整理汇总了Java中com.google.common.collect.ImmutableList.Builder类的典型用法代码示例。如果您正苦于以下问题:Java Builder类的具体用法?Java Builder怎么用?Java Builder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Builder类属于com.google.common.collect.ImmutableList包,在下文中一共展示了Builder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collectRegisteredProviders
import com.google.common.collect.ImmutableList.Builder; //导入依赖的package包/类
private static Builder<DefaultQuickfixProvider> collectRegisteredProviders() {
final Builder<DefaultQuickfixProvider> builder = ImmutableList.<DefaultQuickfixProvider> builder();
if (Platform.isRunning()) {
final IConfigurationElement[] elements = getQuickfixSupplierElements();
for (final IConfigurationElement element : elements) {
try {
final Object extension = element.createExecutableExtension(CLAZZ_PROPERTY_NAME);
if (extension instanceof QuickfixProviderSupplier) {
builder.add(((QuickfixProviderSupplier) extension).get());
}
} catch (final CoreException e) {
LOGGER.error("Error while instantiating quickfix provider supplier instance.", e);
}
}
}
return builder;
}
示例2: getN4JSSourceContainers
import com.google.common.collect.ImmutableList.Builder; //导入依赖的package包/类
public ImmutableList<? extends IN4JSSourceContainer> getN4JSSourceContainers(N4JSProject project) {
ImmutableList.Builder<IN4JSSourceContainer> result = ImmutableList.builder();
URI location = project.getLocation();
ProjectDescription description = getProjectDescription(location);
if (description != null) {
List<SourceFragment> sourceFragments = newArrayList(from(description.getSourceFragment()));
sourceFragments.sort((f1, fDIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT) -> f1
.compareByFragmentType(fDIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT));
for (SourceFragment sourceFragment : sourceFragments) {
List<String> paths = sourceFragment.getPaths();
for (String path : paths) {
// XXX poor man's canonical path conversion. Consider headless compiler with npm projects.
final String relativeLocation = ".".equals(path) ? "" : path;
IN4JSSourceContainer sourceContainer = this.createProjectN4JSSourceContainer(project,
sourceFragment.getSourceFragmentType(), relativeLocation);
result.add(sourceContainer);
}
}
}
return result.build();
}
示例3: getSourceContainers
import com.google.common.collect.ImmutableList.Builder; //导入依赖的package包/类
public ImmutableList<IN4JSSourceContainer> getSourceContainers(N4JSArchive archive) {
ImmutableList.Builder<IN4JSSourceContainer> result = ImmutableList.builder();
URI location = archive.getLocation();
ProjectDescription description = getProjectDescription(location);
if (description != null) {
List<SourceFragment> sourceFragments = newArrayList(from(description.getSourceFragment()));
sourceFragments.sort((f1, fDIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT) -> f1
.compareByFragmentType(fDIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT));
for (SourceFragment sourceFragment : sourceFragments) {
List<String> paths = sourceFragment.getPaths();
for (String path : paths) {
result.add(createArchiveN4JSSourceContainer(archive, sourceFragment.getSourceFragmentType(), path));
}
}
}
return result.build();
}
示例4: prepareMainModuleResolveProcessBuilder
import com.google.common.collect.ImmutableList.Builder; //导入依赖的package包/类
/**
* Prepares process builder configured to invoke Node.js for main module resolution.
*
* @param packageRoot
* package name to resolve.
* @return configured process builder
*/
public ProcessBuilder prepareMainModuleResolveProcessBuilder(File packageRoot) {
final Builder<String> builder = ImmutableList.<String> builder();
NodeJsBinary nodeBinary = nodeBinaryProvider.get();
if (isWindows()) {
builder.add(WIN_SHELL_COMAMNDS);
builder.add(escapeBinaryPath(nodeBinary.getBinaryAbsolutePath()));
builder.add("-e");
builder.add("console.log(require.resolve('" + packageRoot.getName() + "'));");
} else {
builder.add(NIX_SHELL_COMAMNDS);
builder.add(escapeBinaryPath(nodeBinary.getBinaryAbsolutePath())
+ " -e \"console.log(require.resolve('" + packageRoot.getName() + "'));\"");
}
return create(builder.build(), nodeBinary, packageRoot, false);
}
示例5: getNpmCacheCleanProcessBuilder
import com.google.common.collect.ImmutableList.Builder; //导入依赖的package包/类
/**
* Prepares process builder for "npm cache clean" command.
*
* @param invokationPath
* location on which npm command should be invoked
* @return configured, operating system aware process builder for "npm cache clean" command
*/
public ProcessBuilder getNpmCacheCleanProcessBuilder(File invokationPath) {
Builder<String> builder = ImmutableList.<String> builder();
NpmBinary npmBinary = npmBinaryProvider.get();
if (isWindows()) {
builder.add(WIN_SHELL_COMAMNDS);
builder.add(escapeBinaryPath(npmBinary.getBinaryAbsolutePath()), "cache", "clean", "--force");
} else {
builder.add(NIX_SHELL_COMAMNDS);
builder.add(
escapeBinaryPath(npmBinary.getBinaryAbsolutePath()) + " cache clean --force");
}
return create(builder.build(), npmBinary, invokationPath, false);
}
示例6: simpleCall
import com.google.common.collect.ImmutableList.Builder; //导入依赖的package包/类
/**
* Prepares process builder for simple npm commands, e.g. "npm install" or "npm uninstall". Specific command should
* be passed without surrounding spaces or or quotes.
*
* @param invokationPath
* location on which npm command should be invoked
* @param packageName
* package passed as parameter to the command (might be space separated list of names)
* @param save
* instructs npm to save command result to packages in package.json (if available)
* @param simpleCommand
* command to execute
* @return configured, operating system aware process builder for given command
*/
private ProcessBuilder simpleCall(File invokationPath, String packageName, boolean save, String simpleCommand) {
Builder<String> builder = ImmutableList.<String> builder();
NpmBinary npmBinary = npmBinaryProvider.get();
String saveCommand = save ? NPM_OPTION_SAVE : "";
if (isWindows()) {
builder.add(WIN_SHELL_COMAMNDS);
builder.add(escapeBinaryPath(npmBinary.getBinaryAbsolutePath()), simpleCommand, packageName, saveCommand);
} else {
builder.add(NIX_SHELL_COMAMNDS);
builder.add(
escapeBinaryPath(npmBinary.getBinaryAbsolutePath()) + " " + simpleCommand + " " + packageName + " "
+ saveCommand);
}
return create(builder.build(), npmBinary, invokationPath, false);
}
示例7: readAllNames
import com.google.common.collect.ImmutableList.Builder; //导入依赖的package包/类
public static ImmutableList<String> readAllNames(Path path) {
if (path != null) {
Builder<String> namesBuilder = new ImmutableList.Builder<String>();
try (DictionaryReader reader = new DictionaryReader(path);) {
String name = reader.readName();
while (!name.isEmpty()) {
namesBuilder.add(name);
name = reader.readName();
}
} catch (IOException e) {
System.err.println("Unable to create dictionary from file " + path.toString());
}
return namesBuilder.build();
} else {
return ImmutableList.of();
}
}
示例8: findRole
import com.google.common.collect.ImmutableList.Builder; //导入依赖的package包/类
/**
* Returns {@link ProjectRole}s of the specified secret of a {@link TokenInfo}.
*/
public CompletionStage<Map<String, ProjectRole>> findRole(String secret) {
requireNonNull(secret, "secret");
final String q = "$[?(@.tokens[?(@.secret == \"" + secret +
"\")] empty false && @.removed != true)]";
return query(q)
.thenApply(MetadataService::toProjectInfoList)
.thenApply(list -> {
final ImmutableMap.Builder<String, ProjectRole> builder = new ImmutableMap.Builder<>();
list.forEach(p -> p.tokens().stream()
.filter(t -> t.secret().equals(secret))
.findFirst()
.ifPresent(m -> builder.put(p.name(), m.role())));
return builder.build();
});
}
示例9: convertRequest
import com.google.common.collect.ImmutableList.Builder; //导入依赖的package包/类
@Override
public Object convertRequest(ServiceRequestContext ctx, AggregatedHttpMessage request,
Class<?> expectedResultType) throws Exception {
final JsonNode node = (JsonNode) super.convertRequest(ctx, request, JsonNode.class);
if (node.get("changes") != null) {
// have one entry or more than one entry
final JsonNode changeNode = node.get("changes");
final Builder<Change<?>> builder = ImmutableList.builder();
for (JsonNode change : changeNode) {
builder.add(readChange(change));
}
final ImmutableList<Change<?>> changes = builder.build();
checkArgument(!changes.isEmpty(), "should have at least one change.");
return changes;
}
// have only one entry
return ImmutableList.of(readChange(node));
}
示例10: getTaskFilters
import com.google.common.collect.ImmutableList.Builder; //导入依赖的package包/类
@SuppressWarnings("nls")
@Override
public List<TaskListSubsearch> getTaskFilters()
{
Builder<TaskListSubsearch> notificationFilters = ImmutableList.builder();
notificationFilters.add(factory.create(NotifcationPortalConstants.ID_ALL, "", false));
notificationFilters.add(factory.create("notewentlive", Notification.REASON_WENTLIVE, true));
notificationFilters.add(factory.create("notewentlive2", Notification.REASON_WENTLIVE2, true));
notificationFilters.add(factory.create("notemylive", Notification.REASON_MYLIVE, true));
notificationFilters.add(factory.create("noterejected", Notification.REASON_REJECTED, true));
notificationFilters.add(factory.create("notebadurl", Notification.REASON_BADURL, true));
notificationFilters.add(factory.create("noteoverdue", Notification.REASON_OVERDUE, true));
notificationFilters.add(factory.create("noteerror", Notification.REASON_SCRIPT_ERROR, true));
notificationFilters.add(factory.create("noteexecuted", Notification.REASON_SCRIPT_EXECUTED, true));
return notificationFilters.build();
}
示例11: testVectorData
import com.google.common.collect.ImmutableList.Builder; //导入依赖的package包/类
/**
* Loads a list of tests based on the json-encoded test vector files.
*/
@Parameters(name = "Test Vector {index}: {0}")
public static Collection<TestVector> testVectorData() throws Exception {
final URI baseUri =
ValidVectorTest.class.getResource(ValidVectorTest.class.getSimpleName() + ".class").toURI();
final File baseDirectoryFile = new File(baseUri).getParentFile();
final File validTestVectorDir = new File(baseDirectoryFile, "/vectors/valid");
final Builder<TestVector> vectors = ImmutableList.builder();
final ObjectMapper mapper = new ObjectMapper();
Arrays.stream(validTestVectorDir.listFiles()).forEach(file -> {
try {
if (file.getName().endsWith(".json")) {
TestVector vector = mapper.readValue(file, TestVector.class);
vector.setName(file.getName().substring(0, file.getName().length() - 5));
vectors.add(vector);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
});
return vectors.build();
}
示例12: runConcurrent
import com.google.common.collect.ImmutableList.Builder; //导入依赖的package包/类
/**
* Concurrently runs one or more instances of {@link Runnable} in a multithreaded fashion,
* relying upon {@code numThreads} for concurrency.
*/
protected void runConcurrent(final int numThreads, final Runnable... runnableTest)
throws InterruptedException {
final Builder<Runnable> builder = ImmutableList.builder();
// For each runnableTest, add it numThreads times to the bulider.
for (final Runnable runnable : runnableTest) {
for (int i = 0; i < numThreads; i++) {
builder.add(runnable);
}
}
logger.info(String.format("About to run %s threads...", numThreads));
// Actually runs the Runnables above using multiple threads.
assertConcurrent("Test did not complete before the harness timed-out. Please consider "
+ "increasing the timeout value for this test.", builder.build(), 15);
logger.info(String.format("Ran %s threads!", numThreads));
}
示例13: flatten
import com.google.common.collect.ImmutableList.Builder; //导入依赖的package包/类
private static List<Tokenizer> flatten(List<Tokenizer> simplifiers) {
Builder<Tokenizer> flattend = ImmutableList.builder();
for (Tokenizer s : simplifiers) {
if (s instanceof Recursive) {
// Tokenizers controls the creation of recursive tokenizers
// all recursive tokenizers are flat so we don't have
// to flatten recursively
final Recursive c = (Recursive) s;
flattend.addAll(c.getTokenizers());
} else {
flattend.add(s);
}
}
return flattend.build();
}
示例14: computeBranding
import com.google.common.collect.ImmutableList.Builder; //导入依赖的package包/类
public void computeBranding()
{
if (brandings == null)
{
Builder<String> brd = ImmutableList.builder();
brd.add(Loader.instance().getMCVersionString());
brd.add(Loader.instance().getMCPVersionString());
brd.add("Powered by Forge " + ForgeVersion.getVersion());
if (sidedDelegate!=null)
{
brd.addAll(sidedDelegate.getAdditionalBrandingInformation());
}
if (Loader.instance().getFMLBrandingProperties().containsKey("fmlbranding"))
{
brd.add(Loader.instance().getFMLBrandingProperties().get("fmlbranding"));
}
int tModCount = Loader.instance().getModList().size();
int aModCount = Loader.instance().getActiveModList().size();
brd.add(String.format("%d mod%s loaded, %d mod%s active", tModCount, tModCount!=1 ? "s" :"", aModCount, aModCount!=1 ? "s" :"" ));
brandings = brd.build();
brandingsNoMC = brandings.subList(1, brandings.size());
}
}
示例15: addTableFromStatements
import com.google.common.collect.ImmutableList.Builder; //导入依赖的package包/类
/**
* @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 " + qualifiedTableName(table) + " NOPARALLEL LOGGING");
if (!primaryKeysForTable(table).isEmpty()) {
result.add("ALTER INDEX " + schemaNamePrefix() + primaryKeyConstraintName(table.getName()) + " NOPARALLEL LOGGING");
}
result.addAll(buildRemainingStatementsAndComments(table));
return result.build();
}