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


Java Builder.add方法代碼示例

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


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

示例1: adaptMIPResult

import com.google.common.collect.ImmutableSet.Builder; //導入方法依賴的package包/類
protected XORAllocation<T> adaptMIPResult(IMIPResult mipResult) {
    Map<Bidder<T>, BidderAllocation<T>> trades = new HashMap<>();
    for (Bidder<T> bidder : auction.getBidders()) {
        double totalValue = 0;
        Builder<Good> goodsBuilder = ImmutableSet.<Good>builder();
        Builder<XORValue<T>> bundleBids = ImmutableSet.<XORValue<T>>builder();
        for (XORValue<T> bundleBid : auction.getBid(bidder).getValues()) {
            if (DoubleMath.fuzzyEquals(mipResult.getValue(getBidVariable(bundleBid)), 1, 1e-3)) {
                goodsBuilder.addAll(bundleBid.getLicenses());
                bundleBids.add(bundleBid);
                totalValue += bundleBid.value().doubleValue();
            }
        }
        Set<Good> goods = goodsBuilder.build();
        if (!goods.isEmpty()) {
            trades.put(bidder, new BidderAllocation<>(totalValue, new Bundle<>(goods), bundleBids.build()));
        }
    }

    return new XORAllocation<>(trades);
}
 
開發者ID:spectrumauctions,項目名稱:sats-opt,代碼行數:22,代碼來源:WinnerDetermination.java

示例2: getClassesToCheck

import com.google.common.collect.ImmutableSet.Builder; //導入方法依賴的package包/類
private synchronized Collection<Class<?>> getClassesToCheck()
{
	if( classesToCheck == null )
	{
		Builder<Class<?>> builder = ImmutableSet.builder();
		builder.addAll(STATIC_CLASSES_TO_CHECK);
		List<Extension> extensions = domainParamTracker.getExtensions();
		for( Extension extension : extensions )
		{
			Collection<Parameter> clazzes = extension.getParameters("class");
			for( Parameter clazzParam : clazzes )
			{
				builder.add(domainParamTracker.getClassForName(extension, clazzParam.valueAsString()));
			}
		}
		classesToCheck = builder.build();
	}
	return classesToCheck;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:20,代碼來源:SecurityAttributeSource.java

示例3: getDrillUserConfigurableLogicalRules

import com.google.common.collect.ImmutableSet.Builder; //導入方法依賴的package包/類
/**
 * Get a list of logical rules that can be turned on or off by session/system options.
 *
 * If a rule is intended to always be included with the logical set, it should be added
 * to the immutable list created in the getDrillBasicRules() method below.
 *
 * @param optimizerRulesContext - used to get the list of planner settings, other rules may
 *                                also in the future need to get other query state from this,
 *                                such as the available list of UDFs (as is used by the
 *                                DrillMergeProjectRule created in getDrillBasicRules())
 * @return - a list of rules that have been filtered to leave out
 *         rules that have been turned off by system or session settings
 */
public static RuleSet getDrillUserConfigurableLogicalRules(OptimizerRulesContext optimizerRulesContext) {
  final PlannerSettings ps = optimizerRulesContext.getPlannerSettings();

  // This list is used to store rules that can be turned on an off
  // by user facing planning options
  final Builder<RelOptRule> userConfigurableRules = ImmutableSet.<RelOptRule>builder();

  if (ps.isConstantFoldingEnabled()) {
    // TODO - DRILL-2218
    userConfigurableRules.add(ReduceExpressionsRule.PROJECT_INSTANCE);

    userConfigurableRules.add(DrillReduceExpressionsRule.FILTER_INSTANCE_DRILL);
    userConfigurableRules.add(DrillReduceExpressionsRule.CALC_INSTANCE_DRILL);
  }

  return new DrillRuleSet(userConfigurableRules.build());
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:31,代碼來源:DrillRuleSets.java

示例4: getIncomingChannels

import com.google.common.collect.ImmutableSet.Builder; //導入方法依賴的package包/類
public Set<String> getIncomingChannels(Plugin plugin) {
    if (plugin == null) {
        throw new IllegalArgumentException("Plugin cannot be null");
    }

    synchronized (incomingLock) {
        Set<PluginMessageListenerRegistration> registrations = incomingByPlugin.get(plugin);

        if (registrations != null) {
            Builder<String> builder = ImmutableSet.builder();

            for (PluginMessageListenerRegistration registration : registrations) {
                builder.add(registration.getChannel());
            }

            return builder.build();
        } else {
            return ImmutableSet.of();
        }
    }
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:22,代碼來源:StandardMessenger.java

示例5: getIncomingChannelRegistrations

import com.google.common.collect.ImmutableSet.Builder; //導入方法依賴的package包/類
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(Plugin plugin, String channel) {
    if (plugin == null) {
        throw new IllegalArgumentException("Plugin cannot be null");
    }
    validateChannel(channel);

    synchronized (incomingLock) {
        Set<PluginMessageListenerRegistration> registrations = incomingByPlugin.get(plugin);

        if (registrations != null) {
            Builder<PluginMessageListenerRegistration> builder = ImmutableSet.builder();

            for (PluginMessageListenerRegistration registration : registrations) {
                if (registration.getChannel().equals(channel)) {
                    builder.add(registration);
                }
            }

            return builder.build();
        } else {
            return ImmutableSet.of();
        }
    }
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:25,代碼來源:StandardMessenger.java

示例6: modelToList

import com.google.common.collect.ImmutableSet.Builder; //導入方法依賴的package包/類
@Override
protected ImmutableList<ValueAssignment> modelToList() {
  scala.collection.Map<ModelLocation, ModelValue> interpretation = model.interpretation();

  // first get the addresses of arrays
  Map<IdealInt, ITerm> arrays = getArrayAddresses(interpretation);

  // then iterate over the model and generate the assignments
  Builder<ValueAssignment> assignments = ImmutableSet.builder();
  Iterator<Tuple2<ModelLocation, ModelValue>> it2 = interpretation.iterator();
  while (it2.hasNext()) {
    Tuple2<ModelLocation, ModelValue> entry = it2.next();
    ValueAssignment assignment = getAssignment(entry._1, entry._2, arrays);
    if (assignment != null) {
      assignments.add(assignment);
    }
  }

  return assignments.build().asList();
}
 
開發者ID:sosy-lab,項目名稱:java-smt,代碼行數:21,代碼來源:PrincessModel.java

示例7: solve

import com.google.common.collect.ImmutableSet.Builder; //導入方法依賴的package包/類
public void solve() throws IloException{
	long startms = System.currentTimeMillis();
	cplex.solve();
	long endms = System.currentTimeMillis();
	this.solveTimeSeconds = (endms - startms)/1000.0;
	if(this.displayOutput){
		System.out.println("objective: " + cplex.getObjValue());
	}
	Builder<E> setBuilder = ImmutableSet.builder();
	for(E edge: kepInstance.getGraph().getEdges()){
		if(CplexUtil.doubleToBoolean(cplex.getValue(this.phaseOneProblem.indicatorEdgeSelected(edge)))){
			setBuilder.add(edge);
		}
	}
	this.edgesInSolution = setBuilder.build();
}
 
開發者ID:rma350,項目名稱:kidneyExchange,代碼行數:17,代碼來源:TwoStageEdgeFailureSolver.java

示例8: adaptArgumentValue

import com.google.common.collect.ImmutableSet.Builder; //導入方法依賴的package包/類
@Override
public Collection<SchemaNodeIdentifier> adaptArgumentValue(
        final StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement,
            EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement>> ctx,
        final QNameModule targetModule) {
    final Builder<SchemaNodeIdentifier> builder = ImmutableSet.builder();
    boolean replaced = false;
    for (final SchemaNodeIdentifier arg : ctx.getStatementArgument()) {
        final QName qname = arg.getLastComponent();
        if (!targetModule.equals(qname.getModule())) {
            final QName newQname = ctx.getFromNamespace(QNameCacheNamespace.class,
                    QName.create(targetModule, qname.getLocalName()));
            builder.add(SchemaNodeIdentifier.SAME.createChild(newQname));
            replaced = true;
        } else {
            builder.add(arg);
        }
    }

    // This makes sure we reuse the collection when a grouping is
    // instantiated in the same module
    return replaced ? builder.build() : ctx.getStatementArgument();
}
 
開發者ID:opendaylight,項目名稱:yangtools,代碼行數:24,代碼來源:KeyStatementSupport.java

示例9: download

import com.google.common.collect.ImmutableSet.Builder; //導入方法依賴的package包/類
@GET
@Path("{id}/download")
@RequiresRoles(UserRole.ROLE_ADMIN)
@Produces(MediaType.TEXT_PLAIN)
public Response download(@PathParam("id") long id) {
	Course course = courseDao.findById(id);
	Builder<String> setBuilder = ImmutableSet.builder();
	if (course.getProjects().isEmpty()) {
		return Response.status(Status.NO_CONTENT).entity("This course doesn't have any projects").build();
	} else {
		for (Project project : course.getProjects()) {
			if (project.getSourceCodeUrl() == null) {
				LOG.warn("This project doesnt have a source code URL: {}", project);
			} else {
				setBuilder.add(project.getSourceCodeUrl());
			}
		}
		Set<String> sourceCodeurls = setBuilder.build();
		return Response.ok(repoDownloader.prepareDownload(sourceCodeurls)).build();
	}
}
 
開發者ID:devhub-tud,項目名稱:devhub-prototype,代碼行數:22,代碼來源:CoursesResources.java

示例10: getPermutationsConditions

import com.google.common.collect.ImmutableSet.Builder; //導入方法依賴的package包/類
private Set<String> getPermutationsConditions(ResourceContext context,
    List<String> permutationAxes) {
  Builder<String> setBuilder = ImmutableSet.builder();
  PropertyOracle oracle = context.getGeneratorContext().getPropertyOracle();

  for (String permutationAxis : permutationAxes) {
    String propValue = null;
    try {
      SelectionProperty selProp = oracle.getSelectionProperty(null,
          permutationAxis);
      propValue = selProp.getCurrentValue();
    } catch (BadPropertyValueException e) {
      try {
        ConfigurationProperty confProp = oracle.getConfigurationProperty(permutationAxis);
        propValue = confProp.getValues().get(0);
      } catch (BadPropertyValueException e1) {
        e1.printStackTrace();
      }
    }

    if (propValue != null) {
      setBuilder.add(permutationAxis + ":" + propValue);
    }
  }
  return setBuilder.build();
}
 
開發者ID:jDramaix,項目名稱:gss.gwt,代碼行數:27,代碼來源:GssResourceGenerator.java

示例11: processTemplateDef

import com.google.common.collect.ImmutableSet.Builder; //導入方法依賴的package包/類
private void processTemplateDef(Builder<TagHandler> handlers, Element defElement)
    throws TemplateParserException {
  Attr tagAttribute = defElement.getAttributeNode(TAG_ATTRIBUTE);
  if (tagAttribute == null) {
    throw new TemplateParserException("Missing tag attribute on TemplateDef");
  }

  ImmutableSet.Builder<TemplateResource> resources = ImmutableSet.builder();
  
  Element scriptElement = (Element) DomUtil.getFirstNamedChildNode(defElement, JAVASCRIPT_TAG);
  if (scriptElement != null) {
    resources.add(TemplateResource.newJavascriptResource(scriptElement.getTextContent(), this));
  }
  
  Element styleElement = (Element) DomUtil.getFirstNamedChildNode(defElement, STYLE_TAG);
  if (styleElement != null) {
    resources.add(TemplateResource.newStyleResource(styleElement.getTextContent(), this));
  }

  Element templateElement = (Element) DomUtil.getFirstNamedChildNode(defElement, TEMPLATE_TAG);
  TagHandler handler = createHandler(tagAttribute.getNodeValue(), templateElement,
      resources.build());
  if (handler != null) {
    handlers.add(handler);
  }
}
 
開發者ID:inevo,項目名稱:shindig-1.1-BETA5-incubating,代碼行數:27,代碼來源:XmlTemplateLibrary.java

示例12: getParts

import com.google.common.collect.ImmutableSet.Builder; //導入方法依賴的package包/類
public Set<ComplexEntityPart> getParts() {
    Builder<ComplexEntityPart> builder = ImmutableSet.builder();

    for (EntityDragonPart part : getHandle().dragonPartArray) {
        builder.add((ComplexEntityPart) part.getBukkitEntity());
    }

    return builder.build();
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:10,代碼來源:CraftEnderDragon.java

示例13: verifyTableSize

import com.google.common.collect.ImmutableSet.Builder; //導入方法依賴的package包/類
@GwtIncompatible // RegularImmutableSet.table not in emulation
private void verifyTableSize(int inputSize, int setSize, int tableSize) {
  Builder<Integer> builder = ImmutableSet.builder();
  for (int i = 0; i < inputSize; i++) {
    builder.add(i % setSize);
  }
  ImmutableSet<Integer> set = builder.build();
  assertTrue(set instanceof RegularImmutableSet);
  assertEquals("Input size " + inputSize + " and set size " + setSize,
      tableSize, ((RegularImmutableSet<Integer>) set).table.length);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:12,代碼來源:ImmutableSetTest.java

示例14: mergedRuleSets

import com.google.common.collect.ImmutableSet.Builder; //導入方法依賴的package包/類
public static RuleSet mergedRuleSets(RuleSet...ruleSets) {
  final Builder<RelOptRule> relOptRuleSetBuilder = ImmutableSet.builder();
  for (final RuleSet ruleSet : ruleSets) {
    for (final RelOptRule relOptRule : ruleSet) {
      relOptRuleSetBuilder.add(relOptRule);
    }
  }
  return new DrillRuleSet(relOptRuleSetBuilder.build());
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:10,代碼來源:DrillRuleSets.java

示例15: toStringSet

import com.google.common.collect.ImmutableSet.Builder; //導入方法依賴的package包/類
static Set<String> toStringSet(ResultSet resultSet) throws SQLException {
  Builder<String> builder = ImmutableSet.builder();
  final List<Ord<String>> columns = columnLabels(resultSet);
  while (resultSet.next()) {
    StringBuilder buf = new StringBuilder();
    for (Ord<String> column : columns) {
      buf.append(column.i == 1 ? "" : "; ").append(column.e).append("=").append(resultSet.getObject(column.i));
    }
    builder.add(buf.toString());
    buf.setLength(0);
  }
  return builder.build();
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:14,代碼來源:JdbcAssert.java


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