當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。