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


Java LinkedHashMultimap類代碼示例

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


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

示例1: createPluginManager

import com.google.common.collect.LinkedHashMultimap; //導入依賴的package包/類
public static PluginManager createPluginManager(String pluginFileName) {

    try {
      SetMultimap<String, Class<?>> info = LinkedHashMultimap.create();
      Enumeration<URL> resourcesFiles = PluginManager.class.getClassLoader().getResources(pluginFileName);

      while (resourcesFiles.hasMoreElements()) {
        URL url = resourcesFiles.nextElement();
        Properties properties = new Properties();
        loadProperties(url, properties);
        buildPluginNames(info, properties);
      }

      return new PluginManager(info);

    } catch (IOException e) {

      throw new GenerationException(e);
    }

  }
 
開發者ID:mulesoft-labs,項目名稱:raml-java-tools,代碼行數:22,代碼來源:PluginManager.java

示例2: checkConstructorInitialization

import com.google.common.collect.LinkedHashMultimap; //導入依賴的package包/類
/**
 * @param entities field init info
 * @param state visitor state
 * @return a map from each constructor C to the nonnull fields that C does *not* initialize
 */
private SetMultimap<MethodTree, Symbol> checkConstructorInitialization(
    FieldInitEntities entities, VisitorState state) {
  SetMultimap<MethodTree, Symbol> result = LinkedHashMultimap.create();
  Set<Symbol> nonnullInstanceFields = entities.nonnullInstanceFields();
  Trees trees = Trees.instance(JavacProcessingEnvironment.instance(state.context));
  for (MethodTree constructor : entities.constructors()) {
    if (constructorInvokesAnother(constructor, state)) {
      continue;
    }
    Set<Element> guaranteedNonNull =
        guaranteedNonNullForConstructor(entities, state, trees, constructor);
    for (Symbol fieldSymbol : nonnullInstanceFields) {
      if (!guaranteedNonNull.contains(fieldSymbol)) {
        result.put(constructor, fieldSymbol);
      }
    }
  }
  return result;
}
 
開發者ID:uber,項目名稱:NullAway,代碼行數:25,代碼來源:NullAway.java

示例3: identifyDuplicates

import com.google.common.collect.LinkedHashMultimap; //導入依賴的package包/類
private void identifyDuplicates(List<ModContainer> mods)
{
    TreeMultimap<ModContainer, File> dupsearch = TreeMultimap.create(new ModIdComparator(), Ordering.arbitrary());
    for (ModContainer mc : mods)
    {
        if (mc.getSource() != null)
        {
            dupsearch.put(mc, mc.getSource());
        }
    }

    ImmutableMultiset<ModContainer> duplist = Multisets.copyHighestCountFirst(dupsearch.keys());
    SetMultimap<ModContainer, File> dupes = LinkedHashMultimap.create();
    for (Entry<ModContainer> e : duplist.entrySet())
    {
        if (e.getCount() > 1)
        {
            FMLLog.severe("Found a duplicate mod %s at %s", e.getElement().getModId(), dupsearch.get(e.getElement()));
            dupes.putAll(e.getElement(),dupsearch.get(e.getElement()));
        }
    }
    if (!dupes.isEmpty())
    {
        throw new DuplicateModsFoundException(dupes);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:27,代碼來源:Loader.java

示例4: readKeys

import com.google.common.collect.LinkedHashMultimap; //導入依賴的package包/類
/**
 * Read Semeval keys file.
 *
 * @param path path to keys file
 * @return map from sense IDs onto senses
 */
private static SetMultimap<String, String> readKeys(String path) {
    try (BufferedReader reader = new BufferedReader(new FileReader(path))) {
        SetMultimap<String, String> keys = LinkedHashMultimap.create();
        String line;
        while ((line = reader.readLine()) != null) {
            if (line.isEmpty()) {
                continue;
            }
            String[] fields = line.split(" ");
            for (int i = 1; i < fields.length; ++i) {
                keys.put(fields[0], fields[i]);
            }
        }
        return keys;
    } catch (IOException e) {
        throw new RuntimeException("Error reading sense keys file", e);
    }
}
 
開發者ID:clearwsd,項目名稱:clearwsd,代碼行數:25,代碼來源:SemevalReader.java

示例5: computeAllOperations

import com.google.common.collect.LinkedHashMultimap; //導入依賴的package包/類
protected List<IResolvedOperation> computeAllOperations() {
	JvmType rawType = getRawType();
	if (!(rawType instanceof JvmDeclaredType)) {
		return Collections.emptyList();
	}
	Multimap<String, AbstractResolvedOperation> processedOperations = LinkedHashMultimap.create();
	for (IResolvedOperation resolvedOperation : getDeclaredOperations()) {
		processedOperations.put(resolvedOperation.getDeclaration().getSimpleName(), (AbstractResolvedOperation) resolvedOperation);
	}
	if (targetVersion.isAtLeast(JavaVersion.JAVA8)) {
		computeAllOperationsFromSortedSuperTypes((JvmDeclaredType) rawType, processedOperations);
	} else {
		Set<JvmType> processedTypes = Sets.newHashSet(rawType);
		computeAllOperationsFromSuperTypes((JvmDeclaredType) rawType, processedOperations, processedTypes);
	}
	// make sure the declared operations are the first in the list
	List<IResolvedOperation> result = new ArrayList<IResolvedOperation>(processedOperations.size());
	result.addAll(getDeclaredOperations());
	for (AbstractResolvedOperation operation : processedOperations.values()) {
		if (operation.getDeclaration().getDeclaringType() != rawType) {
			result.add(operation);
		}
	}
	return Collections.unmodifiableList(result);
}
 
開發者ID:eclipse,項目名稱:xtext-extras,代碼行數:26,代碼來源:ResolvedFeatures.java

示例6: denormalize

import com.google.common.collect.LinkedHashMultimap; //導入依賴的package包/類
protected Map<String, Collection<String>> denormalize(Multimap<Class<?>, Class<?>> classMapping) {
	Multimap<String, String> result = LinkedHashMultimap.create();
	for(Map.Entry<Class<?>, Class<?>> entry: classMapping.entries()) {
		Class<?> key = entry.getKey();
		Class<?> keyObjectType = ReflectionUtil.getObjectType(key);
		Class<?> value = entry.getValue();
		for(Method method: value.getDeclaredMethods()) {
			if (Modifier.isStatic(method.getModifiers()) && method.getParameterTypes().length > 0) {
				Class<?> paramType = method.getParameterTypes()[0];
				Class<?> paramObjectType = ReflectionUtil.getObjectType(paramType);		
				if (keyObjectType.isAssignableFrom(paramObjectType)) {
					result.put(paramObjectType.getCanonicalName(), value.getCanonicalName());
				}
			}
		}
	}
	return ImmutableMultimap.copyOf(result).asMap();
}
 
開發者ID:eclipse,項目名稱:xtext-extras,代碼行數:19,代碼來源:StaticImplicitMethodsFeatureForTypeProvider.java

示例7: getJavaStubSource

import com.google.common.collect.LinkedHashMultimap; //導入依賴的package包/類
public String getJavaStubSource(IEObjectDescription description, IResourceDescription resourceDescription) {
	if(isNestedType(description) || !isJvmDeclaredType(description)) {
		return null;
	}
	Multimap<QualifiedName, IEObjectDescription> owner2nested = LinkedHashMultimap.create();
	for(IEObjectDescription other: resourceDescription.getExportedObjects()) {
		if(isJvmDeclaredType(other) && isNestedType(other))
			owner2nested.put(getOwnerClassName(other.getQualifiedName()), other);
	}
	StringBuilder classSignatureBuilder = new StringBuilder();
	QualifiedName qualifiedName = description.getQualifiedName();
	if (qualifiedName.getSegments().size() > 1) {
		String string = qualifiedName.toString();
		classSignatureBuilder.append("package " + string.substring(0, string.lastIndexOf('.')) + ";");
	}
	appendType(description, owner2nested, classSignatureBuilder);
	return classSignatureBuilder.toString();
}
 
開發者ID:eclipse,項目名稱:xtext-extras,代碼行數:19,代碼來源:EObjectDescriptionBasedStubGenerator.java

示例8: getAliasedElements

import com.google.common.collect.LinkedHashMultimap; //導入依賴的package包/類
protected Iterable<IEObjectDescription> getAliasedElements(Iterable<IEObjectDescription> candidates) {
	Multimap<QualifiedName, IEObjectDescription> keyToDescription = LinkedHashMultimap.create();
	Multimap<QualifiedName, ImportNormalizer> keyToNormalizer = HashMultimap.create();

	for (IEObjectDescription imported : candidates) {
		QualifiedName fullyQualifiedName = imported.getName();
		for (ImportNormalizer normalizer : normalizers) {
			QualifiedName alias = normalizer.deresolve(fullyQualifiedName);
			if (alias != null) {
				QualifiedName key = alias;
				if (isIgnoreCase()) {
					key = key.toLowerCase();
				}
				keyToDescription.put(key, new AliasedEObjectDescription(alias, imported));
				keyToNormalizer.put(key, normalizer);
			}
		}
	}
	for (QualifiedName name : keyToNormalizer.keySet()) {
		if (keyToNormalizer.get(name).size() > 1)
			keyToDescription.removeAll(name);
	}
	return keyToDescription.values();
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:25,代碼來源:ImportScope.java

示例9: after

import com.google.common.collect.LinkedHashMultimap; //導入依賴的package包/類
public void after(EObject grammarElement) {
	EObject foundGrammarElement = removeLast(grammarElements);
	if (grammarElement != foundGrammarElement)
		throw new IllegalStateException(
				"expected element: '" + grammarElement + "', but was: '" + foundGrammarElement + "'");
	if (grammarElement instanceof UnorderedGroup && indexToHandledElements != null) {
		indexToHandledElements.removeAll(grammarElements.size());
	} else if (!grammarElements.isEmpty()) {
		int index = grammarElements.size() - 1;
		if (grammarElements.get(index) instanceof UnorderedGroup) {
			if (indexToHandledElements == null) {
				indexToHandledElements = LinkedHashMultimap.create();
			}
			indexToHandledElements.put(index, (AbstractElement) grammarElement);
		}
	}
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:18,代碼來源:BaseInternalContentAssistParser.java

示例10: process

import com.google.common.collect.LinkedHashMultimap; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public boolean process(MorphDictionary dict, Lemma.Builder lemmaBuilder,
                       Multimap<String, Wordform> wfMap) {
    Multimap<String, Wordform> additionalWfs = LinkedHashMultimap.create();
    for (String wfStr : wfMap.keySet()) {
        // alternative wordform string
        String altStr = StringUtils.replaceChars(wfStr, YO_CHARS, YO_REPLACEMENTS);
        if (Objects.equal(wfStr, altStr)) {
            continue;
        } // else wfStr contains 'yo'
        if (wfMap.containsKey(altStr)) {
            // the wordform multimap already contains string without 'yo'
            continue;
        }
        additionalWfs.putAll(altStr, wfMap.get(wfStr));
    }
    wfMap.putAll(additionalWfs);
    return true;
}
 
開發者ID:textocat,項目名稱:textokit-core,代碼行數:23,代碼來源:YoLemmaPostProcessor.java

示例11: after

import com.google.common.collect.LinkedHashMultimap; //導入依賴的package包/類
public void after(EObject grammarElement) {
	EObject foundGrammarElement = grammarElements.remove(grammarElements.size() - 1);
	if (grammarElement != foundGrammarElement)
		throw new IllegalStateException("expected element: '" + grammarElement + "', but was: '"
				+ foundGrammarElement + "'");
	if (grammarElement instanceof UnorderedGroup && indexToHandledElements != null) {
		indexToHandledElements.removeAll(grammarElements.size());
	} else if (!grammarElements.isEmpty()) {
		int index = grammarElements.size() - 1;
		if (grammarElements.get(index) instanceof UnorderedGroup) {
			if (indexToHandledElements == null) {
				indexToHandledElements = LinkedHashMultimap.create();
			}
			indexToHandledElements.put(index, (AbstractElement) grammarElement);
		}
	}
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:18,代碼來源:AbstractInternalContentAssistParser.java

示例12: findLocalReferences

import com.google.common.collect.LinkedHashMultimap; //導入依賴的package包/類
protected void findLocalReferences(Iterable<URI> localTargets, ILocalResourceAccess localResourceAccess,
		final IAcceptor<IReferenceDescription> acceptor, IProgressMonitor monitor) {
	if ((monitor != null && monitor.isCanceled()))
		return;
	final Multimap<URI, URI> resource2target = LinkedHashMultimap.create();
	for (URI targetURI : localTargets) {
		resource2target.put(targetURI.trimFragment(), targetURI);
	}
	final SubMonitor subMonitor = SubMonitor.convert(monitor, resource2target.keySet().size());
	for (final URI resourceURI : resource2target.keySet()) {
		if (subMonitor.isCanceled())
			return;
		localResourceAccess.readOnly(resourceURI, new IUnitOfWork.Void<ResourceSet>() {
			@Override
			public void process(ResourceSet resourceSet) throws Exception {
				Resource resource = resourceSet.getResource(resourceURI, true);
				findLocalReferencesInResource(resource2target.get(resourceURI), resource, acceptor);
			}
		});
		subMonitor.worked(1);
	}
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:23,代碼來源:DefaultReferenceFinder.java

示例13: methodsOn

import com.google.common.collect.LinkedHashMultimap; //導入依賴的package包/類
/**
 * Returns all methods, declared and inherited, on {@code type}, except those specified by
 * {@link Object}.
 *
 * <p>If method B overrides method A, only method B will be included in the return set.
 * Additionally, if methods A and B have the same signature, but are on unrelated interfaces,
 * one will be arbitrarily picked to be returned.
 */
public static ImmutableSet<ExecutableElement> methodsOn(TypeElement type, Elements elements)
    throws CannotGenerateCodeException {
  TypeElement objectType = elements.getTypeElement(Object.class.getCanonicalName());
  SetMultimap<Signature, ExecutableElement> methods = LinkedHashMultimap.create();
  for (TypeElement supertype : getSupertypes(type)) {
    for (ExecutableElement method : methodsIn(supertype.getEnclosedElements())) {
      if (method.getEnclosingElement().equals(objectType)) {
        continue;  // Skip methods specified by Object.
      }
      Signature signature = new Signature(method);
      Iterator<ExecutableElement> iterator = methods.get(signature).iterator();
      while (iterator.hasNext()) {
        ExecutableElement otherMethod = iterator.next();
        if (elements.overrides(method, otherMethod, type)
            || method.getParameters().equals(otherMethod.getParameters())) {
          iterator.remove();
        }
      }
      methods.put(signature, method);
    }
  }
  return ImmutableSet.copyOf(methods.values());
}
 
開發者ID:google,項目名稱:FreeBuilder,代碼行數:32,代碼來源:MethodFinder.java

示例14: groupOperationsByRegex

import com.google.common.collect.LinkedHashMultimap; //導入依賴的package包/類
/**
 * Groups the operations by regex group. The key of the Multimap is the group name.
 * The value of the Multimap is a PathOperation
 *
 * @param allOperations all operations
 * @param headerPattern regex pattern used for determining headers
 * @return Operations grouped by regex
 */
public static Multimap<String, PathOperation> groupOperationsByRegex(List<PathOperation> allOperations, Pattern headerPattern) {

    Multimap<String, PathOperation> operationsGroupedByRegex = LinkedHashMultimap.create();


    for (PathOperation operation : allOperations) {
        String path = operation.getPath();
        Matcher m = headerPattern.matcher(path);

        if (m.matches() && m.group(1) != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("Added path operation '{}' to header '{}'", operation, m.group(1));
            }
            operationsGroupedByRegex.put(m.group(1), operation);
        } else {
            if(logger.isWarnEnabled()) {
                logger.warn("Operation '{}' does not match regex '{}' and will not be included in output", operation, headerPattern.toString());
            }
        }
    }

    return operationsGroupedByRegex;
}
 
開發者ID:Swagger2Markup,項目名稱:swagger2markup,代碼行數:32,代碼來源:RegexUtils.java

示例15: groupOperationsByTag

import com.google.common.collect.LinkedHashMultimap; //導入依賴的package包/類
/**
 * Groups the operations by tag. The key of the Multimap is the tag name.
 * The value of the Multimap is a PathOperation
 *
 * @param allOperations     all operations
 * @param operationOrdering comparator for operations, for a given tag
 * @return Operations grouped by Tag
 */
public static Multimap<String, PathOperation> groupOperationsByTag(List<PathOperation> allOperations, Comparator<PathOperation> operationOrdering) {

    Multimap<String, PathOperation> operationsGroupedByTag;
    if (operationOrdering == null) {
        operationsGroupedByTag = LinkedHashMultimap.create();
    } else {
        operationsGroupedByTag = MultimapBuilder.linkedHashKeys().treeSetValues(operationOrdering).build();
    }
    for (PathOperation operation : allOperations) {
        List<String> tags = operation.getOperation().getTags();

        Validate.notEmpty(tags, "Can't GroupBy.TAGS. Operation '%s' has no tags", operation);
        for (String tag : tags) {
            if (logger.isDebugEnabled()) {
                logger.debug("Added path operation '{}' to tag '{}'", operation, tag);
            }
            operationsGroupedByTag.put(tag, operation);
        }
    }

    return operationsGroupedByTag;
}
 
開發者ID:Swagger2Markup,項目名稱:swagger2markup,代碼行數:31,代碼來源:TagUtils.java


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