当前位置: 首页>>代码示例>>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;未经允许,请勿转载。