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


Java LinkedListMultimap.create方法代碼示例

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


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

示例1: findClashingMembersByName

import com.google.common.collect.LinkedListMultimap; //導入方法依賴的package包/類
/**
 * Find clashes by name.
 *
 * @param myPolyMember
 *            current validated Polyfill
 * @param pivotPolyMember
 *            other polyfill in same project
 * @return pairs of contrandicting or same polyfills.
 */
private ListMultimap<TMember, TMember> findClashingMembersByName(EList<TMember> myPolyMember,
		EList<TMember> pivotPolyMember) {
	ListMultimap<TMember, TMember> ret = LinkedListMultimap.create();
	for (TMember my : myPolyMember) {
		String myName = my.getName();
		if (myName == null)
			continue; // broken AST
		for (TMember other : pivotPolyMember) {
			String otherName = other.getName();
			if (myName.equals(otherName)) {
				ret.put(my, other);
			}
		}
	}
	return ret;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:26,代碼來源:PolyfillValidatorFragment.java

示例2: readReverse

import com.google.common.collect.LinkedListMultimap; //導入方法依賴的package包/類
private ListMultimap<String, Thing> readReverse(JsonReader reader) throws IOException {
  reader.beginObject();
  ListMultimap<String, Thing> reverseMap = LinkedListMultimap.create();
  while (reader.hasNext()) {
    String property = reader.nextName();
    JsonToken token = reader.peek();
    if (token == JsonToken.BEGIN_OBJECT) {
      reverseMap.put(property, readObject(reader));
    } else if (token == JsonToken.BEGIN_ARRAY) {
      reader.beginArray();
      while (reader.hasNext()) {
        reverseMap.put(property, readObject(reader));
      }
      reader.endArray();
    } else {
      throw new JsonLdSyntaxException(
          String.format(
              "Invalid value token %s in @reverse. Should be a JSON-LD object or an "
                  + "array of JSON-LD objects",
              token));
    }
  }
  reader.endObject();
  return reverseMap;
}
 
開發者ID:google,項目名稱:schemaorg-java,代碼行數:26,代碼來源:JsonLdSerializer.java

示例3: checkQuotaLimitNamesAreUnique

import com.google.common.collect.LinkedListMultimap; //導入方法依賴的package包/類
private void checkQuotaLimitNamesAreUnique(Quota quota) {
  ListMultimap<String, QuotaLimit> limitNameCounts = LinkedListMultimap.create();
  for (QuotaLimit limit : quota.getLimitsList()) {
    limitNameCounts.put(limit.getName(), limit);
  }
  for (String limitName : limitNameCounts.keySet()) {
    List<QuotaLimit> limits = limitNameCounts.get(limitName);
    if (limits.size() > 1) {
      error(
          MessageLocationContext.create(Iterables.getLast(limits), "name"),
          "There are %d quota limits with name '%s'.",
          limits.size(),
          limitName);
    }
  }
}
 
開發者ID:googleapis,項目名稱:api-compiler,代碼行數:17,代碼來源:QuotaLimitNameValidator.java

示例4: parseMessage

import com.google.common.collect.LinkedListMultimap; //導入方法依賴的package包/類
public static final ListMultimap<Integer, String> parseMessage(String baseMsg) {
    ListMultimap<Integer, String> dict = LinkedListMultimap.create();
    char[] baseMsgArray = baseMsg.toCharArray();
    int index = 0;
    for (int i = 0; i < baseMsgArray.length; i++) {
        if (baseMsgArray[i] == 0x01) {
            String fixField = baseMsg.substring(index, i);
            char[] fixFieldArray = fixField.toCharArray();
            for (int j = 0; j < fixFieldArray.length; j++) {
                if (fixFieldArray[j] == '=') {
                    String num = fixField.substring(0, j);
                    int n = Integer.parseInt(num);
                    String val = fixField.substring(j + 1, fixField.length());
                    dict.put(n, val);
                    break;
                }
            }
            index = i + 1;
        }
    }
    return dict;
}
 
開發者ID:globalforge,項目名稱:infix,代碼行數:23,代碼來源:StaticTestingUtils.java

示例5: addSession

import com.google.common.collect.LinkedListMultimap; //導入方法依賴的package包/類
/**
 * 
 * @param sid
 * @param serverType
 * @param sequence
 * @param localSession
 * @return
 */
public LocalSession addSession(String serverId,String serverType,int sessionId,LocalSession localSession) {
	if (localSession == null) {
		return null;
	}
	localSession.setServerId(serverId);
	localSession.setServerType(serverType);
	localSession.setId(sessionId);
	localSession.setlistener(this.closeListener);
	localSession.setStatus(ISession.STATUS_WORKING);
	sessionBySid.put(serverId, localSession);
	
	synchronized(sessionByStype) {
		LinkedListMultimap<String, LocalSession> multimap = sessionByStype.get(serverType);
		if (multimap == null) {
			multimap = LinkedListMultimap.create();
			sessionByStype.put(serverType, multimap);
		}
		multimap.put(serverId, localSession);
	}
	return localSession;
}
 
開發者ID:qiuhd2015,項目名稱:anima,代碼行數:30,代碼來源:LocalSessionMgr.java

示例6: NewsSearchRenderableDefinition

import com.google.common.collect.LinkedListMultimap; //導入方法依賴的package包/類
@Inject
public NewsSearchRenderableDefinition(Node content, RD definition, RenderingModel<?> parent, TemplatingFunctions templatingFunctions) {
	super(content, definition, parent);
	this.templatingFunctions = templatingFunctions;
	setWorkspace(NewsRepositoryConstants.COLLABORATION);
	setNodetype(NewsNodeTypes.News.NAME);

	filter = LinkedListMultimap.create();
	Set<String> parameters = webContext.getParameters().keySet();
	for (String parameterKey : parameters) {
		if (allowedParameters().contains(parameterKey)) {
			String[] parameterValues = webContext.getParameterValues(parameterKey);
			for (String parameterValue : parameterValues) {
				if (StringUtils.isNotEmpty(parameterValue)) {
					filter.get(parameterKey).add(parameterValue);
				}
			}
		}
		webContext.remove(parameterKey);
	}
	LOGGER.debug("Running constructor NewsSearchRenderableDefinition");
}
 
開發者ID:tricode,項目名稱:magnolia-news,代碼行數:23,代碼來源:NewsSearchRenderableDefinition.java

示例7: discover

import com.google.common.collect.LinkedListMultimap; //導入方法依賴的package包/類
AutoRegisterModules discover() throws InvalidPluginException {
  sysSingletons = new HashSet<>();
  sysListen = LinkedListMultimap.create();
  initJs = null;

  sshGen.setPluginName(pluginName);
  httpGen.setPluginName(pluginName);

  scan();

  if (!sysSingletons.isEmpty() || !sysListen.isEmpty() || initJs != null) {
    sysModule = makeSystemModule();
  }
  sshModule = sshGen.create();
  httpModule = httpGen.create();
  return this;
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:18,代碼來源:AutoRegisterModules.java

示例8: computeAspectDependencies

import com.google.common.collect.LinkedListMultimap; //導入方法依賴的package包/類
@Override
public ImmutableMultimap<Attribute, Label> computeAspectDependencies(Target target,
    DependencyFilter dependencyFilter)
    throws InterruptedException {
  Multimap<Attribute, Label> result = LinkedListMultimap.create();
  if (target instanceof Rule) {
    Multimap<Attribute, Label> transitions =
        ((Rule) target).getTransitions(DependencyFilter.NO_NODEP_ATTRIBUTES);
    for (Entry<Attribute, Label> entry : transitions.entries()) {
      Target toTarget;
      try {
        toTarget = packageProvider.getTarget(eventHandler, entry.getValue());
        result.putAll(
            AspectDefinition.visitAspectsIfRequired(
                target,
                entry.getKey(),
                toTarget,
                dependencyFilter));
      } catch (NoSuchThingException e) {
        // Do nothing. One of target direct deps has an error. The dependency on the BUILD file
        // (or one of the files included in it) will be reported in the query result of :BUILD.
      }
    }
  }
  return ImmutableMultimap.copyOf(result);
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:27,代碼來源:PreciseAspectResolver.java

示例9: testCopyCredentialToHeaders

import com.google.common.collect.LinkedListMultimap; //導入方法依賴的package包/類
@Test
public void testCopyCredentialToHeaders() throws IOException {
  ListMultimap<String, String> values = LinkedListMultimap.create();
  values.put("Authorization", "token1");
  values.put("Authorization", "token2");
  values.put("Extra-Authorization", "token3");
  values.put("Extra-Authorization", "token4");
  when(credentials.getRequestMetadata(any(URI.class))).thenReturn(Multimaps.asMap(values));
  ClientCall<String, Integer> interceptedCall =
      interceptor.interceptCall(descriptor, CallOptions.DEFAULT, channel);
  Metadata headers = new Metadata();
  interceptedCall.start(listener, headers);
  assertEquals(listener, call.responseListener);
  assertEquals(headers, call.headers);

  Iterable<String> authorization = headers.getAll(AUTHORIZATION);
  Assert.assertArrayEquals(new String[]{"token1", "token2"},
      Iterables.toArray(authorization, String.class));
  Iterable<String> extraAuthorization = headers.getAll(EXTRA_AUTHORIZATION);
  Assert.assertArrayEquals(new String[]{"token3", "token4"},
      Iterables.toArray(extraAuthorization, String.class));
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:23,代碼來源:ClientAuthInterceptorTest.java

示例10: partitionParametersByType

import com.google.common.collect.LinkedListMultimap; //導入方法依賴的package包/類
private Multimap<Type, VariableTree> partitionParametersByType(
    List<VariableTree> parameters, VisitorState state) {

  Types types = state.getTypes();
  Multimap<Type, VariableTree> multimap = LinkedListMultimap.create();

  variables:
  for (VariableTree node : parameters) {
    // Normalize Integer => int
    Type type = types.unboxedTypeOrType(ASTHelpers.getType(node));
    for (Type existingType : multimap.keySet()) {
      if (types.isSameType(existingType, type)) {
        multimap.put(existingType, node);
        continue variables;
      }
    }

    // A new type for the map.
    multimap.put(type, node);
  }

  return multimap;
}
 
開發者ID:google,項目名稱:error-prone,代碼行數:24,代碼來源:AssistedParameters.java

示例11: testCycleDetection

import com.google.common.collect.LinkedListMultimap; //導入方法依賴的package包/類
/**
 * Creates the following graph and verifies that the cycle is found.
 * <pre>
 *         A
 *       /   \
 *     B       C <----|
 *   /   \   /        |
 * D       E          |
 *   \   /            |
 *     F --------------
 * </pre>
 * Note that there is a circular dependency from F -> C -> E -> F.
 */
@Test
public void testCycleDetection() throws IOException {
  Multimap<String, String> graph = LinkedListMultimap.create();
  graph.put("A", "B");
  graph.put("A", "C");
  graph.put("B", "D");
  graph.put("B", "E");
  graph.put("C", "E");
  graph.put("D", "F");
  graph.put("E", "F");
  graph.put("F", "C");
  AbstractAcyclicDepthFirstPostOrderTraversal<String> dfs = new TestDagDepthFirstSearch(graph);

  try {
    dfs.traverse(ImmutableList.of("A"));
  } catch (CycleException e) {
    assertEquals("Cycle found: F -> C -> E -> F", e.getMessage());
    assertEquals(ImmutableList.of("F", "C", "E", "F"), e.getCycle());
  }
}
 
開發者ID:saleehk,項目名稱:buck-cutom,代碼行數:34,代碼來源:AbstractAcyclicDepthFirstPostOrderTraversalTest.java

示例12: testCycleExceptionDoesNotContainUnrelatedNodes

import com.google.common.collect.LinkedListMultimap; //導入方法依賴的package包/類
/**
 * Verifies that the reported cycle mentions only A, B, and D, but not C or E.
 * <pre>
 *         A <---|
 *       /       |
 *     B         |
 *   / | \       |
 * C   D   E     |
 *     |         |
 *     ==========|
 * </pre>
 */
@Test
public void testCycleExceptionDoesNotContainUnrelatedNodes() throws IOException {
  Multimap<String, String> graph = LinkedListMultimap.create();
  graph.put("A", "B");
  graph.put("B", "C");
  graph.put("B", "D");
  graph.put("B", "E");
  graph.put("D", "A");

  TestDagDepthFirstSearch dfs = new TestDagDepthFirstSearch(graph);
  try {
    dfs.traverse(ImmutableList.of("A"));
  } catch (CycleException e) {
    assertEquals("Cycle found: A -> B -> D -> A", e.getMessage());
    assertEquals(ImmutableList.of("A", "B", "D", "A"), e.getCycle());
  }
}
 
開發者ID:saleehk,項目名稱:buck-cutom,代碼行數:30,代碼來源:AbstractAcyclicDepthFirstPostOrderTraversalTest.java

示例13: builderPutAllMultimapWithDuplicates

import com.google.common.collect.LinkedListMultimap; //導入方法依賴的package包/類
@Test
public void builderPutAllMultimapWithDuplicates() {
  Multimap<String, Integer> toPut = LinkedListMultimap.create();
  toPut.put("foo", 1);
  toPut.put("bar", 4);
  toPut.put("foo", 2);
  toPut.put("foo", 1);
  toPut.put("bar", 5);
  Multimap<String, Integer> moreToPut = LinkedListMultimap.create();
  moreToPut.put("foo", 6);
  moreToPut.put("bar", 4);
  moreToPut.put("foo", 7);
  moreToPut.put("foo", 2);
  ImmutableSortedKeyListMultimap.Builder<String, Integer> builder
      = ImmutableSortedKeyListMultimap.builder();
  builder.putAll(toPut);
  builder.putAll(moreToPut);
  Multimap<String, Integer> multimap = builder.build();
  assertThat(multimap).valuesForKey("foo").containsExactly(1, 2, 1, 6, 7, 2).inOrder();
  assertThat(multimap).valuesForKey("bar").containsExactly(4, 5, 4).inOrder();
  assertThat(multimap).hasSize(9);
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:23,代碼來源:ImmutableSortedKeyListMultimapTest.java

示例14: collectSoftwareElementsToMove

import com.google.common.collect.LinkedListMultimap; //導入方法依賴的package包/類
private Multimap<String, SoftwareElement> collectSoftwareElementsToMove(Set<VariationPoint> vpsToMerge,
        VariationPoint survivingVP) {
    Multimap<String, SoftwareElement> variantSoftwareElements = LinkedListMultimap.create();
    for (VariationPoint vp : vpsToMerge) {

        // skip the surviving vp to not modify the emf elements
        if (survivingVP == vp) {
            continue;
        }

        for (Variant variant : vp.getVariants()) {
            variantSoftwareElements.putAll(variant.getId(), variant.getImplementingElements());
        }
    }
    return variantSoftwareElements;
}
 
開發者ID:kopl,項目名稱:SPLevo,代碼行數:17,代碼來源:MergeVariationPointsHandler.java

示例15: invalidBase64

import com.google.common.collect.LinkedListMultimap; //導入方法依賴的package包/類
@Test
public void invalidBase64() throws Exception {
  ListMultimap<String, String> values = LinkedListMultimap.create();
  values.put("Extra-Authorization-bin", "dG9rZW4z1");  // invalid base64
  when(credentials.getRequestMetadata(eq(expectedUri))).thenReturn(Multimaps.asMap(values));

  GoogleAuthLibraryCallCredentials callCredentials =
      new GoogleAuthLibraryCallCredentials(credentials);
  callCredentials.applyRequestMetadata(method, attrs, executor, applier);

  verify(credentials).getRequestMetadata(eq(expectedUri));
  verify(applier).fail(statusCaptor.capture());
  Status status = statusCaptor.getValue();
  assertEquals(Status.Code.UNAUTHENTICATED, status.getCode());
  assertEquals(IllegalArgumentException.class, status.getCause().getClass());
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:17,代碼來源:GoogleAuthLibraryCallCredentialsTest.java


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