当前位置: 首页>>代码示例>>Java>>正文


Java Builder类代码示例

本文整理汇总了Java中com.google.common.collect.ImmutableSet.Builder的典型用法代码示例。如果您正苦于以下问题:Java Builder类的具体用法?Java Builder怎么用?Java Builder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Builder类属于com.google.common.collect.ImmutableSet包,在下文中一共展示了Builder类的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: propertiesOf

import com.google.common.collect.ImmutableSet.Builder; //导入依赖的package包/类
private static void propertiesOf(Builder<String> builder, Class<?> type) {
	if (!type.getPackage().getName().startsWith("java.lang")) {
		Method[] methods = type.getDeclaredMethods();
		for (Method m : methods) {
			if (isVisibleMethod(m)) {
				System.out.println(type+"."+m.getName());
				Maybe<String> propertyName=propertyNameOf(m);
				propertyName.ifPresent(name -> {
					builder.add(name);
				});
			}
		}
		Class<?> superClass = type.getSuperclass();
		if (superClass!=null && superClass!=Object.class) {
			propertiesOf(builder, superClass);
		}
		Class<?>[] interfaces = type.getInterfaces();
		for (Class<?> i:interfaces) {
			propertiesOf(builder, i);
		}
	}
}
 
开发者ID:flapdoodle-oss,项目名称:de.flapdoodle.solid,代码行数:23,代码来源:Inspector.java

示例5: listNodesByIds

import com.google.common.collect.ImmutableSet.Builder; //导入依赖的package包/类
@Override
public Iterable<NodeMetadata> listNodesByIds(Iterable<String> ids) {
   List<Instance> instances = new ArrayList<Instance>();
   for (String id : ids) {
      IAcsClient client = api.getAcsClient(api.decodeToRegion(id));
      DescribeInstancesRequest req = new DescribeInstancesRequest();
      Gson gson = new GsonBuilder().create();
      String iids = gson.toJson(new String[] { api.decodeToId(id) });
      req.setInstanceIds(iids);
      try {
         DescribeInstancesResponse resp = client.getAcsResponse(req);
         instances.addAll(resp.getInstances());
      } catch (Exception e) {
         logger.warn(e.getMessage());
      }
   }
   Builder<NodeMetadata> builder = ImmutableSet.builder();
   builder.addAll(transform(instances, new InstanceToNodeMetadata(api, nodeStatus)));
   return builder.build();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:21,代码来源:ECSComputeServiceAdapter.java

示例6: listNodes

import com.google.common.collect.ImmutableSet.Builder; //导入依赖的package包/类
@Override
public Iterable<NodeMetadata> listNodes() {
   Builder<NodeMetadata> builder = ImmutableSet.builder();
   Set<String> regions = api.getAvailableRegions();
   for (String region : regions) {
      try {
         IAcsClient client = api.getAcsClient(region);
         DescribeInstancesRequest req = new DescribeInstancesRequest();
         DescribeInstancesResponse resp = client.getAcsResponse(req);
         builder.addAll(transform(resp.getInstances(), new InstanceToNodeMetadata(api, nodeStatus)));
      } catch (Exception e) {
         logger.warn(e.getMessage());
      }
   }
   return builder.build();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:17,代码来源:ECSComputeServiceAdapter.java

示例7: listImages

import com.google.common.collect.ImmutableSet.Builder; //导入依赖的package包/类
@Override
public Iterable<Image> listImages() {
   Builder<Image> builder = ImmutableSet.builder();
   Set<String> regions = api.getAvailableRegions();
   for (String region : regions) {
      try {
         IAcsClient client = api.getAcsClient(region);
         DescribeImagesRequest req = new DescribeImagesRequest();
         DescribeImagesResponse resp = client.getAcsResponse(req);
         builder.addAll(transform(resp.getImages(), new ImageToImage(api, region)));
      } catch (Exception e) {
         logger.warn(e.getMessage());
      }
   }
   return builder.build();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:17,代码来源:ECSComputeServiceAdapter.java

示例8: 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

示例9: 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

示例10: 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

示例11: modelToList

import com.google.common.collect.ImmutableSet.Builder; //导入依赖的package包/类
@Override
protected ImmutableList<ValueAssignment> modelToList() {

  Builder<ValueAssignment> assignments = ImmutableSet.builder();

  for (Term t : assertedTerms) {
    creator.extractVariablesAndUFs(
        t,
        true,
        (name, f) -> {
          if (f.getSort().isArraySort()) {
            assignments.addAll(getArrayAssignment(name, f, f, Collections.emptyList()));
          } else {
            assignments.add(getAssignment(name, (ApplicationTerm) f));
          }
        });
  }

  return assignments.build().asList();
}
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:21,代码来源:SmtInterpolModel.java

示例12: combineDimensions

import com.google.common.collect.ImmutableSet.Builder; //导入依赖的package包/类
/**
 * Combines the both positions in such a way, that for each coordinate of the types given in the given set of
 * dimensions have to be
 * <ul>
 * <li>either present in both positions of the pair, and then have to be the same
 * <li>or be present in only one of the both positions
 * </ul>
 *
 * @param left the first of the two positions, whose dimensions should be united
 * @param right the second of the two positions whose dimensions should be combined
 * @param targetDimensions the dimension in which the positions shall be united
 * @return a new position, with the coordinates merged according to the above rules
 */
public static Position combineDimensions(Position left, Position right, Set<Class<?>> targetDimensions) {
    ImmutableSet.Builder<Object> builder = ImmutableSet.builder();
    for (Class<?> dimension : targetDimensions) {
        Object leftCoordinate = left.coordinateFor(dimension);
        Object rightCoordinate = right.coordinateFor(dimension);
        if (Objects.equal(leftCoordinate, rightCoordinate) || oneIsNull(leftCoordinate, rightCoordinate)) {
            builder.add(MoreObjects.firstNonNull(leftCoordinate, rightCoordinate));
        } else {
            throw new IllegalArgumentException(
                    "Coordinates for dimension '" + dimension + "' are neither the same in both positions (" + left
                            + " and " + right + "), nor present only in one. Cannot consistently combine.");
        }
    }
    return Position.of(builder.build());
}
 
开发者ID:tensorics,项目名称:tensorics-core,代码行数:29,代码来源:Positions.java

示例13: testUpdateEndpointGroup

import com.google.common.collect.ImmutableSet.Builder; //导入依赖的package包/类
@Test
public void testUpdateEndpointGroup() throws Throwable {
    Set<Endpoint> expected = ImmutableSet.of(Endpoint.of("127.0.0.1", 8001, 2),
                                             Endpoint.of("127.0.0.1", 8002, 3));
    switch (mode) {
        case IN_NODE_VALUE:
            setNodeValue(NodeValueCodec.DEFAULT.encodeAll(expected));
            break;
        case IN_CHILD_NODES:
            //add two more node
            setNodeChild(expected);
            //construct the final expected node list
            Builder<Endpoint> builder = ImmutableSet.builder();
            builder.addAll(sampleEndpoints).addAll(expected);
            expected = builder.build();
            break;
    }
    try (CloseableZooKeeper zk = connection()) {
        zk.sync(zNode, (rc, path, ctx) -> {
        }, null);
    }

    final Set<Endpoint> finalExpected = expected;
    await().untilAsserted(() -> assertThat(endpointGroup.endpoints()).hasSameElementsAs(finalExpected));
}
 
开发者ID:line,项目名称:armeria,代码行数:26,代码来源:EndpointGroupTest.java

示例14: 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

示例15: ContainerEffectiveStatementImpl

import com.google.common.collect.ImmutableSet.Builder; //导入依赖的package包/类
ContainerEffectiveStatementImpl(
        final StmtContext<QName, ContainerStatement, EffectiveStatement<QName, ContainerStatement>> ctx) {
    super(ctx);
    this.original = (ContainerSchemaNode) ctx.getOriginalCtx().map(StmtContext::buildEffective).orElse(null);
    final ImmutableSet.Builder<ActionDefinition> actionsBuilder = ImmutableSet.builder();
    final Builder<NotificationDefinition> notificationsBuilder = ImmutableSet.builder();
    for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
        if (effectiveStatement instanceof ActionDefinition) {
            actionsBuilder.add((ActionDefinition) effectiveStatement);
        }

        if (effectiveStatement instanceof NotificationDefinition) {
            notificationsBuilder.add((NotificationDefinition) effectiveStatement);
        }
    }

    this.actions = actionsBuilder.build();
    this.notifications = notificationsBuilder.build();
    presence = findFirstEffectiveSubstatement(PresenceEffectiveStatement.class).isPresent();
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:21,代码来源:ContainerEffectiveStatementImpl.java


注:本文中的com.google.common.collect.ImmutableSet.Builder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。