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


Java ImmutableSet类代码示例

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


ImmutableSet类属于com.google.common.collect包,在下文中一共展示了ImmutableSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSingleHostByMacAndVlanFetch

import com.google.common.collect.ImmutableSet; //导入依赖的package包/类
/**
 * Tests fetch of one host by mac and vlan.
 */
@Test
public void testSingleHostByMacAndVlanFetch() {
    final ProviderId pid = new ProviderId("of", "foo");
    final MacAddress mac1 = MacAddress.valueOf("00:00:11:00:00:01");
    final Set<IpAddress> ips1 = ImmutableSet.of(IpAddress.valueOf("1111:1111:1111:1::"));
    final Host host1 =
            new DefaultHost(pid, HostId.hostId(mac1), valueOf(1), vlanId((short) 1),
                    new HostLocation(DeviceId.deviceId("1"), portNumber(11), 1),
                    ips1);

    hosts.add(host1);

    expect(mockHostService.getHost(HostId.hostId("00:00:11:00:00:01/1")))
            .andReturn(host1)
            .anyTimes();
    replay(mockHostService);

    WebTarget wt = target();
    String response = wt.path("hosts/00:00:11:00:00:01/1").request().get(String.class);
    final JsonObject result = Json.parse(response).asObject();
    assertThat(result, matchesHost(host1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:HostResourceTest.java

示例2: fromPossiblyOverlapping

import com.google.common.collect.ImmutableSet; //导入依赖的package包/类
/**
 * Creates an {@code AnswerKey} where the same response may appear both as assessed and
 * unassessed.  This removes any such tuples from the unassessed set before calling {@link
 * #from(com.bbn.bue.common.symbols.Symbol, Iterable, Iterable, CorefAnnotation)}. This is simply
 * provided for convenience.
 */
public static AnswerKey fromPossiblyOverlapping(Symbol docID, Iterable<AssessedResponse> assessed,
    Iterable<Response> unassessedResponses, CorefAnnotation corefAnnotation) {
  final ImmutableSet<AssessedResponse> assessedResponsesSet = ImmutableSet.copyOf(assessed);
  final ImmutableSet<Response> unassessedResponseSet = ImmutableSet.copyOf(unassessedResponses);
  final Set<Response> assessedResponses = FluentIterable.from(assessedResponsesSet)
      .transform(AssessedResponseFunctions.response()).toSet();

  if (Sets.intersection(assessedResponses, unassessedResponseSet).isEmpty()) {
    return from(docID, assessedResponsesSet, unassessedResponseSet, corefAnnotation);
  } else {
    return from(docID, assessedResponsesSet,
        Sets.difference(unassessedResponseSet, assessedResponses),
        corefAnnotation);
  }

}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:23,代码来源:AnswerKey.java

示例3: getSubscribers

import com.google.common.collect.ImmutableSet; //导入依赖的package包/类
/**
 * Gets an iterator representing an immutable snapshot of all subscribers to the given event at
 * the time this method is called.
 */
Iterator<Subscriber> getSubscribers(Object event) {
  ImmutableSet<Class<?>> eventTypes = flattenHierarchy(event.getClass());

  List<Iterator<Subscriber>> subscriberIterators =
      Lists.newArrayListWithCapacity(eventTypes.size());

  for (Class<?> eventType : eventTypes) {
    CopyOnWriteArraySet<Subscriber> eventSubscribers = subscribers.get(eventType);
    if (eventSubscribers != null) {
      // eager no-copy snapshot
      subscriberIterators.add(eventSubscribers.iterator());
    }
  }

  return Iterators.concat(subscriberIterators.iterator());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:21,代码来源:SubscriberRegistry.java

示例4: initialize

import com.google.common.collect.ImmutableSet; //导入依赖的package包/类
/**
 * Invoked by Guice at Injector-creation time to prepare providers for each
 * element in this set. At this time the set's size is known, but its
 * contents are only evaluated when get() is invoked.
 */
@Inject
public void initialize(Injector injector) {
    providers = new ArrayList<>();
    List<Dependency<?>> dependencies = new ArrayList<>();
    for (Binding<?> entry : injector.findBindingsByType(elementType)) {

        if (keyMatches(entry.getKey())) {
            @SuppressWarnings("unchecked") // protected by findBindingsByType()
                    Binding<T> binding = (Binding<T>) entry;
            providers.add(binding.getProvider());
            dependencies.add(Dependency.get(binding.getKey()));
        }
    }

    this.dependencies = ImmutableSet.copyOf(dependencies);
    this.binder = null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:Multibinder.java

示例5: propertyOf

import com.google.common.collect.ImmutableSet; //导入依赖的package包/类
public static ImmutableSet<?> propertyOf(Blob blob, Function<String, Collection<String>> pathPropertyMapping, PropertyCollectionResolver propertyResolver,
			String propertyName) {
		Collection<String> aliasList = pathPropertyMapping.apply(propertyName);
		for (String alias : aliasList) {
//			if (alias.equals("filename")) {
//				return ImmutableSet.of(blob.filename());
//			}
//			if (alias.equals("path")) {
//				return ImmutableSet.of(Joiner.on('/').join(blob.path()));
//			}
			ImmutableSet<?> resolved = propertyResolver.resolve(blob.meta(), Splitter.on('.').split(alias));
			if (!resolved.isEmpty()) {
				return resolved;
			}
		}
		return ImmutableSet.of();
	}
 
开发者ID:flapdoodle-oss,项目名称:de.flapdoodle.solid,代码行数:18,代码来源:Blobs.java

示例6: verifyAssignment

import com.google.common.collect.ImmutableSet; //导入依赖的package包/类
/** Helper method to verify the number of PartitionSenders in a given fragment endpoint assignments */
private static void verifyAssignment(List<Integer> fragmentList,
    ArrayListMultimap<Integer, DrillbitEndpoint> partitionSenderMap) {

  // We expect at least one entry the list
  assertTrue(fragmentList.size() > 0);

  for(Integer majorFragmentId : fragmentList) {
    // we expect the fragment that has DeMux/HashToRandom as sending exchange to have parallelization with not more
    // than the number of nodes in the cluster and each node in the cluster can have at most one assignment
    List<DrillbitEndpoint> assignments = partitionSenderMap.get(majorFragmentId);
    assertNotNull(assignments);
    assertTrue(assignments.size() > 0);
    assertTrue(String.format("Number of partition senders in major fragment [%d] is more than expected", majorFragmentId), CLUSTER_SIZE >= assignments.size());

    // Make sure there are no duplicates in assigned endpoints (i.e at most one partition sender per endpoint)
    assertTrue("Some endpoints have more than one fragment that has ParitionSender", ImmutableSet.copyOf(assignments).size() == assignments.size());
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:20,代码来源:TestLocalExchange.java

示例7: processSpecific

import com.google.common.collect.ImmutableSet; //导入依赖的package包/类
private Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
    log.debug("Processing specific forwarding objective");
    TrafficSelector selector = fwd.selector();
    EthTypeCriterion ethType =
            (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
    if (ethType != null) {
        short et = ethType.ethType().toShort();
        if (et == Ethernet.TYPE_IPV4) {
            return processSpecificRoute(fwd);
        } else if (et == Ethernet.TYPE_VLAN) {
            /* The ForwardingObjective must specify VLAN ethtype in order to use the Transit Circuit */
            return processSpecificSwitch(fwd);
        }
    }

    fail(fwd, ObjectiveError.UNSUPPORTED);
    return ImmutableSet.of();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:AbstractCorsaPipeline.java

示例8: rewriteIdentifiers

import com.google.common.collect.ImmutableSet; //导入依赖的package包/类
private static void rewriteIdentifiers(N4JSGrammarAccess ga,
		ImmutableMap.Builder<AbstractElement, Integer> builder) {
	ImmutableSet<AbstractRule> identifierRules = ImmutableSet.of(
			ga.getBindingIdentifierRule(),
			ga.getIdentifierNameRule(),
			ga.getIDENTIFIERRule());
	for (ParserRule rule : GrammarUtil.allParserRules(ga.getGrammar())) {
		for (EObject obj : EcoreUtil2.eAllContents(rule.getAlternatives())) {
			if (obj instanceof Assignment) {
				Assignment assignment = (Assignment) obj;
				AbstractElement terminal = assignment.getTerminal();
				int type = InternalN4JSParser.RULE_IDENTIFIER;
				if (terminal instanceof CrossReference) {
					terminal = ((CrossReference) terminal).getTerminal();
					type = IDENTIFIER_REF_TOKEN;
				}
				if (terminal instanceof RuleCall) {
					AbstractRule calledRule = ((RuleCall) terminal).getRule();
					if (identifierRules.contains(calledRule)) {
						builder.put(assignment, type);
					}
				}
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:27,代码来源:TokenTypeRewriter.java

示例9: classMappedToMultipleRules

import com.google.common.collect.ImmutableSet; //导入依赖的package包/类
/**
 * Tests behavior when a class is mapped to multiple rules. A runtime exception should be thrown.
 */
@Test
public void classMappedToMultipleRules() {
  ImmutableList<String> lines =
      ImmutableList.of(
          "com.test.stuff,//java/com/test/stuff:target",
          "com.test.stuff,//java/com/test/other:target");
  try {
    (new UserDefinedResolver(lines)).resolve((ImmutableSet.of("com.test.stuff")));
    fail("Expected an exception, but nothing was thrown");
  } catch (IllegalArgumentException e) {
    assertThat(e)
        .hasMessageThat()
        .isEqualTo(
            "com.test.stuff mapped to multiple targets: //java/com/test/other:target, "
                + "//java/com/test/stuff:target");
  }
}
 
开发者ID:bazelbuild,项目名称:BUILD_file_generator,代码行数:21,代码来源:UserDefinedResolverTest.java

示例10: crossReferencedMethods

import com.google.common.collect.ImmutableSet; //导入依赖的package包/类
@Derived
@Auxiliary
ImmutableSet<String> crossReferencedMethods() {
  Set<String> referenced = new HashSet<>();
  for (EncodedElement e : element()) {
    for (Term t : e.code()) {
      if (t.isBinding()) {
        Code.Binding b = (Code.Binding) t;
        if (b.isMethod()) {
          referenced.add(b.identifier());
        }
      }
    }
  }
  return ImmutableSet.copyOf(referenced);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:EncodingInfo.java

示例11: filter

import com.google.common.collect.ImmutableSet; //导入依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
    String usertokenId = requestContext.getHeaderString(Constants.USERTOKENID_HEADER);

    if (Strings.isNullOrEmpty(usertokenId)) {
        return;
    }

    UserToken userToken;
    try {
        userToken = tokenServiceClient.getUserTokenById(usertokenId);
    } catch (TokenServiceClientException e) {
        throw new NotAuthorizedException("UsertokenId: '" + usertokenId + "' not valid", e);
    }

    UibBrukerPrincipal brukerPrincipal = UibBrukerPrincipal.ofUserToken(userToken);
    ImmutableSet<String> tilganger = extractRolesAllowed(userToken, brukerPrincipal.uibBruker);

    requestContext.setSecurityContext(new AutentiseringsContext(brukerPrincipal, tilganger));

    if (authenticatedHandler != null) {
        authenticatedHandler.handle(requestContext);
    }
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:25,代码来源:UserTokenFilter.java

示例12: applyPredicatetoSystemOutput

import com.google.common.collect.ImmutableSet; //导入依赖的package包/类
public static ScoringDataTransformation applyPredicatetoSystemOutput(
    final Predicate<Response> responsePredicate) {
  return new ScoringDataTransformation() {
    @Override
    public ScoringData transform(final ScoringData scoringData) {
      checkArgument(scoringData.argumentOutput().isPresent(), "System output must be present");
      final ImmutableSet.Builder<Response> toDelete = ImmutableSet.builder();
      for (final Response r : scoringData.argumentOutput().get().responses()) {
        if (!responsePredicate.apply(r)) {
          toDelete.add(r);
        }
      }
      return ScoringData.builder().from(scoringData).argumentOutput(
          ResponseMapping.delete(toDelete.build())
              .apply(scoringData.argumentOutput().get())).build();
    }

    @Override
    public void logStats() {

    }
  };
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:24,代码来源:ScoringDataTransformations.java

示例13: testTableWithMixedTypes

import com.google.common.collect.ImmutableSet; //导入依赖的package包/类
@Test
public void testTableWithMixedTypes(DataAccessObject dataAccessObject) throws AlgorithmExecutionException {
    // GIVEN
    Attribute attributeA = new Attribute(new ColumnIdentifier(TABLE_NAME, "a"), Range.closed(1, 3), INTEGER);
    Attribute attributeB = new Attribute(new ColumnIdentifier(TABLE_NAME, "b"), Range.closed(1, 4), INTEGER);
    Attribute attributeC = new Attribute(new ColumnIdentifier(TABLE_NAME, "d"), Range.closed("b", "c"), TEXT);
    Attribute attributeD = new Attribute(new ColumnIdentifier(TABLE_NAME, "c"), Range.closed("a", "z"), TEXT);
    ImmutableList<Attribute> attributes = ImmutableList.of(attributeA, attributeB, attributeC, attributeD);
    TableInfo tableInfo = new TableInfo(TABLE_NAME, attributes);
    InclusionDependency indAB = toInd(attributeA.getColumnIdentifier(), attributeB.getColumnIdentifier());
    InclusionDependency indCD = toInd(attributeC.getColumnIdentifier(), attributeD.getColumnIdentifier());
    ImmutableSet<InclusionDependency> validInds = ImmutableSet.of(indAB, indCD);

    when(dataAccessObject.isValidUIND(any(InclusionDependency.class)))
            .thenAnswer(invocation -> validInds.contains(invocation.<InclusionDependency>getArgument(0)));

    // WHEN
    when(dataAccessObject.getTableInfo(TABLE_NAME)).thenReturn(tableInfo);
    bellBrockhausen.execute();

    // THEN
    assertThat(resultReceiver.getReceivedResults()).containsExactlyInAnyOrder(toArray(validInds));
}
 
开发者ID:HPI-Information-Systems,项目名称:AdvancedDataProfilingSeminar,代码行数:24,代码来源:BellBrockhausenTest.java

示例14: getDrillUserConfigurableLogicalRules

import com.google.common.collect.ImmutableSet; //导入依赖的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

示例15: addToDoc

import com.google.common.collect.ImmutableSet; //导入依赖的package包/类
void addToDoc(Document doc, String... values){
  Preconditions.checkArgument(valueType == String.class);
  if (isSorted()) {
    Preconditions.checkArgument(values.length < 2, "sorted fields cannot have multiple values");
  }

  // add distinct elements to doc
  final Iterable<String> nonNull = FluentIterable.from(Arrays.asList(values))
      .filter(new Predicate<String>() {
        @Override
        public boolean apply(@Nullable final String input) {
          return input != null;
        }
      });

  for (final String value : ImmutableSet.copyOf(nonNull)) {
    final String truncatedValue = StringUtils.abbreviate(value, MAX_STRING_LENGTH);
    doc.add(new StringField(indexFieldName, truncatedValue, stored ? Store.YES : Store.NO));
  }

  if (isSorted() && values.length == 1) {
    Preconditions.checkArgument(sortedValueType == SearchFieldSorting.FieldType.STRING);
    doc.add(new SortedDocValuesField(indexFieldName, new BytesRef(values[0])));
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:26,代码来源:IndexKey.java


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