本文整理汇总了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);
}
示例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;
}
示例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());
}
示例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();
}
}
}
示例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();
}
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}
示例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();
}
示例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);
}
}
示例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();
}
示例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);
}
示例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());
}
示例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();
}