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


Java ImmutableSetMultimap.of方法代碼示例

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


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

示例1: testRoleInference_RoleHierarchyInvolved

import com.google.common.collect.ImmutableSetMultimap; //導入方法依賴的package包/類
@Test //missing role is ambiguous without cardinality constraints
public void testRoleInference_RoleHierarchyInvolved() {
    GraknTx graph = unificationTestSet.tx();
    String relationString = "{($p, subRole2: $gc) isa binary;}";
    String relationString2 = "{(subRole1: $gp, $p) isa binary;}";
    RelationshipAtom relation = (RelationshipAtom) ReasonerQueries.atomic(conjunction(relationString, graph), graph).getAtom();
    RelationshipAtom relation2 = (RelationshipAtom) ReasonerQueries.atomic(conjunction(relationString2, graph), graph).getAtom();
    Multimap<Role, Var> roleMap = roleSetMap(relation.getRoleVarMap());
    Multimap<Role, Var> roleMap2 = roleSetMap(relation2.getRoleVarMap());

    ImmutableSetMultimap<Role, Var> correctRoleMap = ImmutableSetMultimap.of(
            graph.getRole("role"), var("p"),
            graph.getRole("subRole2"), var("gc"));
    ImmutableSetMultimap<Role, Var> correctRoleMap2 = ImmutableSetMultimap.of(
            graph.getRole("role"), var("p"),
            graph.getRole("subRole1"), var("gp"));
    assertEquals(correctRoleMap, roleMap);
    assertEquals(correctRoleMap2, roleMap2);
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:20,代碼來源:AtomicTest.java

示例2: testZipEntryFilter

import com.google.common.collect.ImmutableSetMultimap; //導入方法依賴的package包/類
@Test public void testZipEntryFilter() throws Exception {
  ZipFilterEntryFilter filter =
      new ZipFilterEntryFilter(
          ".*R.class.*",
          ImmutableSetMultimap.of("foo.class", 1L, "baz.class", 2L),
          ImmutableMap.of("foo.class", 1L, "bar.class", 2L, "baz.class", 3L, "res/R.class", 4L),
          HashMismatchCheckMode.WARN);
  filter.accept("foo.class", callback);
  callback.assertOp(FilterOperation.SKIP);
  filter.accept("bar.class", callback);
  callback.assertOp(FilterOperation.COPY);
  filter.accept("baz.class", callback);
  callback.assertOp(FilterOperation.COPY);
  filter.accept("res/R.class", callback);
  callback.assertOp(FilterOperation.SKIP);
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:17,代碼來源:ZipFilterActionTest.java

示例3: testZipEntryFilter_ErrorOnMismatch

import com.google.common.collect.ImmutableSetMultimap; //導入方法依賴的package包/類
@Test public void testZipEntryFilter_ErrorOnMismatch() throws Exception {
  ZipFilterEntryFilter filter =
      new ZipFilterEntryFilter(
          ".*R.class.*",
          ImmutableSetMultimap.of("foo.class", 1L, "baz.class", 2L),
          ImmutableMap.of("foo.class", 1L, "bar.class", 2L, "baz.class", 3L, "res/R.class", 4L),
          HashMismatchCheckMode.ERROR);
  filter.accept("foo.class", callback);
  callback.assertOp(FilterOperation.SKIP);
  filter.accept("bar.class", callback);
  callback.assertOp(FilterOperation.COPY);
  filter.accept("res/R.class", callback);
  callback.assertOp(FilterOperation.SKIP);
  thrown.expect(IllegalStateException.class);
  thrown.expectMessage("name matches but the hash does not.");
  filter.accept("baz.class", callback);
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:18,代碼來源:ZipFilterActionTest.java

示例4: beforeNode

import com.google.common.collect.ImmutableSetMultimap; //導入方法依賴的package包/類
@Override
public void beforeNode(Object obj, DescriptorPath path) {
  Preconditions.checkState(!refsStack.containsKey(path));

  SetMultimap<ReferenceType, String> refs = getRelatedPaths(obj, path);
  SetMultimap<ReferenceType, String> newRefs = LinkedHashMultimap.create();

  for (Map.Entry<ReferenceType, Collection<String>> entry : refs.asMap().entrySet()) {
    ReferenceType type = entry.getKey();
    for (String reference : entry.getValue()) {
      if (!allowedRefs.containsEntry(type, reference)) {
        newRefs.put(type, reference);
        allowedRefs.put(type, reference);
      }
    }
  }

  // consolidate into the singleton if it's empty
  newRefs = newRefs.size() == 0 ? ImmutableSetMultimap
      .<ReferenceType, String> of() : newRefs;
  refsStack.put(path, newRefs);

  callReferenceConstraints(obj, path);
}
 
開發者ID:cloudera,項目名稱:cm_ext,代碼行數:25,代碼來源:ReferenceValidatorImpl.java

示例5: testRuleApplicability_WithWildcard_MissingMappings

import com.google.common.collect.ImmutableSetMultimap; //導入方法依賴的package包/類
@Test
public void testRuleApplicability_WithWildcard_MissingMappings(){
    GraknTx graph = ruleApplicabilitySet.tx();
    //although singleRoleEntity plays only one role it can also play an implicit role of the resource so mapping ambiguous
    String relationString = "{($x, $y, $z);$y isa singleRoleEntity; $z isa singleRoleEntity;}";
    RelationshipAtom relation = (RelationshipAtom) ReasonerQueries.atomic(conjunction(relationString, graph), graph).getAtom();
    ImmutableSetMultimap<Role, Var> roleMap = ImmutableSetMultimap.of(
            graph.getRole("role"), var("x"),
            graph.getRole("role"), var("y"),
            graph.getRole("role"), var("z"));
    assertEquals(roleMap, roleSetMap(relation.getRoleVarMap()));
    assertThat(relation.getApplicableRules().collect(toSet()), empty());
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:14,代碼來源:AtomicTest.java

示例6: testRoleInference_TypedBinaryRelation

import com.google.common.collect.ImmutableSetMultimap; //導入方法依賴的package包/類
/**
 * ##################################
 *
 *       ROLE INFERENCE Tests
 *
 * ##################################
 */

@Test
public void testRoleInference_TypedBinaryRelation(){
    GraknTx graph = roleInferenceSet.tx();
    String patternString = "{($x, $y); $x isa entity1; $y isa entity2;}";
    String patternString2 = "{($x, $y) isa binary; $x isa entity1; $y isa entity2;}";

    ImmutableSetMultimap<Role, Var> correctRoleMap = ImmutableSetMultimap.of(
            graph.getRole("role1"), var("x"),
            graph.getRole("role2"), var("y"));
    roleInference(patternString, correctRoleMap, graph);
    roleInference(patternString2, correctRoleMap, graph);
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:21,代碼來源:AtomicTest.java

示例7: testRoleInference_TypedBinaryRelation_SingleTypeMissing

import com.google.common.collect.ImmutableSetMultimap; //導入方法依賴的package包/類
@Test
public void testRoleInference_TypedBinaryRelation_SingleTypeMissing(){
    GraknTx graph = roleInferenceSet.tx();
    String patternString = "{($x, $y); $x isa entity1;}";
    String patternString2 = "{($x, $y) isa binary; $x isa entity1;}";

    ImmutableSetMultimap<Role, Var> correctRoleMap = ImmutableSetMultimap.of(
            graph.getRole("role1"), var("x"),
            graph.getRole("role"), var("y"));
    roleInference(patternString, correctRoleMap, graph);
    roleInference(patternString2, correctRoleMap, graph);
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:13,代碼來源:AtomicTest.java

示例8: testRoleInference_TypedTernaryRelationWithKnownRole

import com.google.common.collect.ImmutableSetMultimap; //導入方法依賴的package包/類
@Test //each type maps to a specific role
public void testRoleInference_TypedTernaryRelationWithKnownRole(){
    GraknTx graph = roleInferenceSet.tx();
    String patternString = "{($x, $y, role3: $z);$x isa entity1;$y isa entity2;}";
    String patternString2 = "{($x, $y, role3: $z) isa ternary;$x isa entity1;$y isa entity2;}";

    ImmutableSetMultimap<Role, Var> correctRoleMap = ImmutableSetMultimap.of(
            graph.getRole("role1"), var("x"),
            graph.getRole("role2"), var("y"),
            graph.getRole("role3"), var("z"));
    roleInference(patternString, correctRoleMap, graph);
    roleInference(patternString2, correctRoleMap, graph);
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:14,代碼來源:AtomicTest.java

示例9: testRoleInference_TypedTernaryRelation

import com.google.common.collect.ImmutableSetMultimap; //導入方法依賴的package包/類
@Test //without cardinality constraints the $y variable can be mapped to any of the three roles hence metarole is assigned
public void testRoleInference_TypedTernaryRelation(){
    GraknTx graph = roleInferenceSet.tx();
    String patternString = "{($x, $y, $z);$x isa entity1;$y isa entity2;}";
    String patternString2 = "{($x, $y, $z) isa ternary;$x isa entity1;$y isa entity2;}";

    ImmutableSetMultimap<Role, Var> correctRoleMap = ImmutableSetMultimap.of(
            graph.getRole("role1"), var("x"),
            graph.getRole("role2"), var("y"),
            graph.getRole("role"), var("z"));
    roleInference(patternString, correctRoleMap, graph);
    roleInference(patternString2, correctRoleMap, graph);
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:14,代碼來源:AtomicTest.java

示例10: testRoleInference_TernaryRelationWithRepeatingRolePlayers

import com.google.common.collect.ImmutableSetMultimap; //導入方法依賴的package包/類
@Test
public void testRoleInference_TernaryRelationWithRepeatingRolePlayers(){
    GraknTx graph = roleInferenceSet.tx();
    String patternString = "{(role1: $x, role2: $y, $y);}";
    String patternString2 = "{(role1: $x, role2: $y, $y) isa ternary;}";

    ImmutableSetMultimap<Role, Var> correctRoleMap = ImmutableSetMultimap.of(
            graph.getRole("role1"), var("x"),
            graph.getRole("role2"), var("y"),
            graph.getRole("role"), var("y"));
    roleInference(patternString, correctRoleMap, graph);
    roleInference(patternString2, correctRoleMap, graph);
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:14,代碼來源:AtomicTest.java

示例11: testRoleInference_TypedTernaryRelation_TypesPlaySubRoles_SubRolesAreCorrectlyIdentified

import com.google.common.collect.ImmutableSetMultimap; //導入方法依賴的package包/類
@Test
public void testRoleInference_TypedTernaryRelation_TypesPlaySubRoles_SubRolesAreCorrectlyIdentified(){
    GraknTx graph = roleInferenceSet.tx();
    String patternString = "{(role: $x, role: $y, role: $z); $x isa anotherEntity1; $y isa anotherEntity2; $z isa anotherEntity3;}";
    String patternString2 = "{(role: $x, role: $y, role: $z) isa ternary; $x isa anotherEntity1; $y isa anotherEntity2; $z isa anotherEntity3;}";

    ImmutableSetMultimap<Role, Var> correctRoleMap = ImmutableSetMultimap.of(
            graph.getRole("subRole1"), var("x"),
            graph.getRole("subRole2"), var("y"),
            graph.getRole("subRole3"), var("z"));
    roleInference(patternString, correctRoleMap, graph);
    roleInference(patternString2, correctRoleMap, graph);
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:14,代碼來源:AtomicTest.java

示例12: testRoleInference_TypedTernaryRelationWithMetaRoles_MetaRolesShouldBeOverwritten

import com.google.common.collect.ImmutableSetMultimap; //導入方法依賴的package包/類
@Test
public void testRoleInference_TypedTernaryRelationWithMetaRoles_MetaRolesShouldBeOverwritten(){
    GraknTx graph = roleInferenceSet.tx();
    String patternString = "{(role: $x, role: $y, role: $z); $x isa entity1; $y isa entity2; $z isa entity3;}";
    String patternString2 = "{(role: $x, role: $y, role: $z) isa ternary; $x isa entity1; $y isa entity2; $z isa entity3;}";

    ImmutableSetMultimap<Role, Var> correctRoleMap = ImmutableSetMultimap.of(
            graph.getRole("role1"), var("x"),
            graph.getRole("role2"), var("y"),
            graph.getRole("role3"), var("z"));
    roleInference(patternString, correctRoleMap, graph);
    roleInference(patternString2, correctRoleMap, graph);
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:14,代碼來源:AtomicTest.java

示例13: testRoleInference_TypedTernaryRelation_TypesAreSubTypes_TopRolesShouldBeChosen

import com.google.common.collect.ImmutableSetMultimap; //導入方法依賴的package包/類
@Test
public void testRoleInference_TypedTernaryRelation_TypesAreSubTypes_TopRolesShouldBeChosen(){
    GraknTx graph = roleInferenceSet.tx();
    String patternString = "{(role: $x, role: $y, role: $z); $x isa subEntity1; $y isa subEntity2; $z isa subEntity3;}";
    String patternString2 = "{(role: $x, role: $y, role: $z) isa ternary; $x isa subEntity1; $y isa subEntity2; $z isa subEntity3;}";

    ImmutableSetMultimap<Role, Var> correctRoleMap = ImmutableSetMultimap.of(
            graph.getRole("role1"), var("x"),
            graph.getRole("role2"), var("y"),
            graph.getRole("role3"), var("z"));
    roleInference(patternString, correctRoleMap, graph);
    roleInference(patternString2, correctRoleMap, graph);
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:14,代碼來源:AtomicTest.java

示例14: testRoleInference_TypedTernaryRelation_TypesCanPlayMultipleRoles_MetaRoleIsChosen

import com.google.common.collect.ImmutableSetMultimap; //導入方法依賴的package包/類
@Test
public void testRoleInference_TypedTernaryRelation_TypesCanPlayMultipleRoles_MetaRoleIsChosen(){
    GraknTx graph = roleInferenceSet.tx();
    String patternString = "{($x, $y, $z); $x isa genericEntity; $y isa genericEntity; $z isa genericEntity;}";
    String patternString2 = "{($x, $y, $z) isa ternary; $x isa genericEntity; $y isa genericEntity; $z isa genericEntity;}";

    ImmutableSetMultimap<Role, Var> correctRoleMap = ImmutableSetMultimap.of(
            graph.getRole("role"), var("x"),
            graph.getRole("role"), var("y"),
            graph.getRole("role"), var("z"));
    roleInference(patternString, correctRoleMap, graph);
    roleInference(patternString2, correctRoleMap, graph);
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:14,代碼來源:AtomicTest.java

示例15: testRoleInference_RoleMappingUnambiguous

import com.google.common.collect.ImmutableSetMultimap; //導入方法依賴的package包/類
@Test //entity1 plays role1, entity2 plays 2 roles, entity3 plays 3 roles hence ambiguous and metarole has to be assigned, EXPECTED TO CHANGE WITH CARDINALITY CONSTRAINTS
public void testRoleInference_RoleMappingUnambiguous(){
    GraknTx graph = ruleApplicabilitySet.tx();
    String relationString = "{($x, $y, $z) isa ternary;$x isa singleRoleEntity; $y isa twoRoleEntity; $z isa threeRoleEntity;}";
    RelationshipAtom relation = (RelationshipAtom) ReasonerQueries.atomic(conjunction(relationString, graph), graph).getAtom();
    ImmutableSetMultimap<Role, Var> roleMap = ImmutableSetMultimap.of(
            graph.getRole("role1"), var("x"),
            graph.getRole("role"), var("y"),
            graph.getRole("role"), var("z"));
    assertEquals(roleMap, roleSetMap(relation.getRoleVarMap()));
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:12,代碼來源:AtomicTest.java


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