當前位置: 首頁>>代碼示例>>Java>>正文


Java Builder.add方法代碼示例

本文整理匯總了Java中com.google.common.collect.ImmutableList.Builder.add方法的典型用法代碼示例。如果您正苦於以下問題:Java Builder.add方法的具體用法?Java Builder.add怎麽用?Java Builder.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.collect.ImmutableList.Builder的用法示例。


在下文中一共展示了Builder.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: renameTableStatements

import com.google.common.collect.ImmutableList.Builder; //導入方法依賴的package包/類
/**
 * @see org.alfasoftware.morf.jdbc.SqlDialect#renameTableStatements(java.lang.String, java.lang.String)
 */
@Override
public Collection<String> renameTableStatements(Table from, Table to) {

  Builder<String> builder = ImmutableList.<String>builder();

  if (!primaryKeysForTable(from).isEmpty()) {
    builder.add(dropPrimaryKeyConstraintStatement(from));
  }

  builder.add("ALTER TABLE " + from.getName() + " RENAME TO " + to.getName());

  if (!primaryKeysForTable(to).isEmpty()) {
    builder.add(addPrimaryKeyConstraintStatement(to, namesOfColumns(primaryKeysForTable(to))));
  }

  return builder.build();
}
 
開發者ID:alfasoftware,項目名稱:morf,代碼行數:21,代碼來源:H2Dialect.java

示例2: 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);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:24,代碼來源:NodeProcessBuilder.java

示例3: 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);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:23,代碼來源:NodeProcessBuilder.java

示例4: 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);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:32,代碼來源:NodeProcessBuilder.java

示例5: renameTableStatements

import com.google.common.collect.ImmutableList.Builder; //導入方法依賴的package包/類
/**
 * @see org.alfasoftware.morf.jdbc.SqlDialect#renameTableStatements(java.lang.String, java.lang.String)
 */
@Override
public Collection<String> renameTableStatements(Table from, Table to) {

  Builder<String> builder = ImmutableList.<String>builder();

  if (!primaryKeysForTable(from).isEmpty()) {
    builder.add(dropPrimaryKeyConstraintStatement(from));
  }

  builder.add("ALTER TABLE " + qualifiedTableName(from) + " RENAME TO " + qualifiedTableName(to));

  if (!primaryKeysForTable(to).isEmpty()) {
    builder.add(addPrimaryKeyConstraintStatement(to, namesOfColumns(primaryKeysForTable(to))));
  }

  return builder.build();
}
 
開發者ID:alfasoftware,項目名稱:morf,代碼行數:21,代碼來源:NuoDBDialect.java

示例6: 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));
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:21,代碼來源:ChangesRequestConverter.java

示例7: renameTableStatements

import com.google.common.collect.ImmutableList.Builder; //導入方法依賴的package包/類
@Override
public Collection<String> renameTableStatements(Table fromTable, Table toTable) {
  String from = fromTable.getName();
  String to = toTable.getName();
  Builder<String> builder = ImmutableList.<String>builder();

  builder.add("IF EXISTS (SELECT 1 FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(N'" + from + "_version_DF') AND type = (N'D')) exec sp_rename N'" + from + "_version_DF', N'" + to + "_version_DF'");

  if (!primaryKeysForTable(fromTable).isEmpty()) {
    builder.add("sp_rename N'" + from + "." + from + "_PK', N'" + to + "_PK', N'INDEX'");
  }

  builder.add("sp_rename N'" + from + "', N'" + to + "'");

  return builder.build();
}
 
開發者ID:alfasoftware,項目名稱:morf,代碼行數:17,代碼來源:SqlServerDialect.java

示例8: 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));
}
 
開發者ID:hyperledger,項目名稱:quilt,代碼行數:22,代碼來源:AbstractCryptoConditionTest.java

示例9: keywordPairs

import com.google.common.collect.ImmutableList.Builder; //導入方法依賴的package包/類
@Override
public List<Pair<ISemanticRegion, ISemanticRegion>> keywordPairs(Keyword kw1, Keyword kw2) {
	Preconditions.checkNotNull(kw1);
	Preconditions.checkNotNull(kw2);
	Preconditions.checkArgument(kw1 != kw2);
	Predicate<ISemanticRegion> p1 = createPredicate(kw1);
	Predicate<ISemanticRegion> p2 = createPredicate(kw2);
	List<ISemanticRegion> all = findAll(Predicates.or(p1, p2));
	Builder<Pair<ISemanticRegion, ISemanticRegion>> result = ImmutableList.builder();
	LinkedList<ISemanticRegion> stack = new LinkedList<ISemanticRegion>();
	for (ISemanticRegion region : all) {
		if (p1.apply(region))
			stack.push(region);
		else if (!stack.isEmpty())
			result.add(Pair.of(stack.pop(), region));
	}
	return result.build();
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:19,代碼來源:AbstractSemanticRegionsFinder.java

示例10: disambiguate

import com.google.common.collect.ImmutableList.Builder; //導入方法依賴的package包/類
/**
 * Moves type annotations in {@code annotations} to {@code type}, and adds any declaration
 * annotations on {@code type} to {@code declarationAnnotations}.
 */
private static Type disambiguate(
    Env<ClassSymbol, TypeBoundClass> env,
    ElementType declarationTarget,
    Type type,
    ImmutableList<AnnoInfo> annotations,
    Builder<AnnoInfo> declarationAnnotations) {
  // desugar @Repeatable annotations before disambiguating: annotation containers may target
  // a subset of the types targeted by their element annotation
  annotations = groupRepeated(env, annotations);
  ImmutableList.Builder<AnnoInfo> typeAnnotations = ImmutableList.builder();
  for (AnnoInfo anno : annotations) {
    Set<ElementType> target = env.get(anno.sym()).annotationMetadata().target();
    if (target.contains(ElementType.TYPE_USE)) {
      typeAnnotations.add(anno);
    }
    if (target.contains(declarationTarget)) {
      declarationAnnotations.add(anno);
    }
  }
  return addAnnotationsToType(type, typeAnnotations.build());
}
 
開發者ID:google,項目名稱:turbine,代碼行數:26,代碼來源:DisambiguateTypeAnnotations.java

示例11: getGreetings

import com.google.common.collect.ImmutableList.Builder; //導入方法依賴的package包/類
public List<Greeting> getGreetings() {
  // This query requires the index defined in index.yaml to work because of the orderBy on date.
  EntityQuery query =
      Query.newEntityQueryBuilder()
          .setKind("Greeting")
          .setFilter(hasAncestor(key))
          .setOrderBy(desc("date"))
          .setLimit(5)
          .build();

  QueryResults<Entity> results = getDatastore().run(query);

  Builder<Greeting> resultListBuilder = ImmutableList.builder();
  while (results.hasNext()) {
    resultListBuilder.add(new Greeting(results.next()));
  }

  return resultListBuilder.build();
}
 
開發者ID:GoogleCloudPlatform,項目名稱:java-docs-samples,代碼行數:20,代碼來源:Guestbook.java

示例12: readList

import com.google.common.collect.ImmutableList.Builder; //導入方法依賴的package包/類
public static <T> List<T> readList(ChannelBuffer bb, int length, OFMessageReader<T> reader) throws OFParseError {
    int end = bb.readerIndex() + length;
    Builder<T> builder = ImmutableList.<T>builder();
    if(logger.isTraceEnabled())
        logger.trace("readList(length={}, reader={})", length, reader.getClass());
    while(bb.readerIndex() < end) {
        T read = reader.readFrom(bb);
        if(logger.isTraceEnabled())
            logger.trace("readList: read={}, left={}", read, end - bb.readerIndex());
        builder.add(read);
    }
    if(bb.readerIndex() != end) {
        throw new IllegalStateException("Overread length: length="+length + " overread by "+ (bb.readerIndex() - end) + " reader: "+reader);
    }
    return builder.build();
}
 
開發者ID:o3project,項目名稱:openflowj-otn,代碼行數:17,代碼來源:ChannelUtils.java

示例13: modelToList

import com.google.common.collect.ImmutableList.Builder; //導入方法依賴的package包/類
@Override
protected ImmutableList<ValueAssignment> modelToList() {
  Builder<ValueAssignment> assignments = ImmutableList.builder();

  long modelIterator = msat_model_create_iterator(model);
  while (msat_model_iterator_has_next(modelIterator)) {
    long[] key = new long[1];
    long[] value = new long[1];
    if (msat_model_iterator_next(modelIterator, key, value)) {
      throw new NoSuchElementException();
    }

    if (msat_is_array_type(creator.getEnv(), msat_term_get_type(value[0]))) {
      assignments.addAll(getArrayAssignments(key[0], key[0], value[0], Collections.emptyList()));
    } else {
      assignments.add(getAssignment(key[0], value[0]));
    }
  }
  msat_destroy_model_iterator(modelIterator);
  return assignments.build();
}
 
開發者ID:sosy-lab,項目名稱:java-smt,代碼行數:22,代碼來源:Mathsat5Model.java

示例14: replaceOrAdd

import com.google.common.collect.ImmutableList.Builder; //導入方法依賴的package包/類
/**
 * Replace an element in a list with another, or adds the element if the element did not exist in the list.
 *
 * @param <T>    Element type.
 * @param elts   Elements to replace element in.
 * @param oldElt Element to replace.
 * @param newElt Element to replace it with
 * @return New List with oldElt replaced.
 */
public static <T> List<T> replaceOrAdd(final List<T> elts, final T oldElt, final T newElt) {
    final Builder<T> builder = ImmutableList.builder();
    boolean shouldAdd = true;
    for (final T elt : elts) {
        if (elt.equals(oldElt)) {
            builder.add(newElt);
            shouldAdd = false;
            break;
        } else {
            builder.add(elt);
        }
    }
    if (shouldAdd) {
        builder.add(newElt);
    }
    return builder.build();
}
 
開發者ID:tomtom-international,項目名稱:speedtools,代碼行數:27,代碼來源:Immutables.java

示例15: generateCoveredPaths

import com.google.common.collect.ImmutableList.Builder; //導入方法依賴的package包/類
/**
 * Generate the covered paths, reducing to the lowest depth.
 *
 * @param structureHierarchy
 *            the structure hierarchy
 * @param coveredStructures
 *            the covered structures
 * @param depth
 *            the maximum depth
 * @return list of paths for the covered structures
 */
private List<String> generateCoveredPaths(ItemHierarchy<Structure> structureHierarchy,
		List<Structure> coveredStructures, int depth) {
	LinkedHashSet<String> collect = coveredStructures.stream()
			.map(s -> structureHierarchy.getSelectorPath(s).toDepth(depth).toString())
			.collect(Collectors.toCollection(LinkedHashSet::new));

	Builder<String> builder = ImmutableList.<String>builder();
	String parent = collect.iterator().next();
	builder.add(parent);
	for (String path : collect) {
		if (!path.startsWith(parent)) {
			builder.add(path);
			parent = path;
		}
	}

	return builder.build();
}
 
開發者ID:dstl,項目名稱:baleen,代碼行數:30,代碼來源:TemplateRecordConfigurationCreatingConsumer.java


注:本文中的com.google.common.collect.ImmutableList.Builder.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。