本文整理汇总了Java中com.google.common.collect.LinkedHashMultimap.create方法的典型用法代码示例。如果您正苦于以下问题:Java LinkedHashMultimap.create方法的具体用法?Java LinkedHashMultimap.create怎么用?Java LinkedHashMultimap.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.LinkedHashMultimap
的用法示例。
在下文中一共展示了LinkedHashMultimap.create方法的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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例6: 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);
}
}
}
示例7: 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();
}
示例8: groupByRelatedSourceEvents
import com.google.common.collect.LinkedHashMultimap; //导入方法依赖的package包/类
/**
* Returns the group of correlated events per source where the group of related source events
* produces the same downstream events
*
* @param sources the set of source component names
* @return the group of correlated events per source
*/
public List<Set<String>> groupByRelatedSourceEvents(Set<String> sources) {
Multimap<Set<String>, String> allEventsToSourceEvents = LinkedHashMultimap.create();
Stream<String> rootEventIds = events.stream().filter(e -> e != null && e.getRootIds().isEmpty())
.map(EventInformation::getEventId);
rootEventIds.forEach(rootEventId -> {
Map<String, EventInformation> allRelatedEvents = buildRelatedEventsMap(rootEventId);
allEventsToSourceEvents.put(allRelatedEvents.keySet(), rootEventId);
});
List<Set<String>> result = new ArrayList<>();
allEventsToSourceEvents.asMap().values().forEach(v ->
result.add(new HashSet<>(v))
);
return result;
}
示例9: 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;
}
示例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;
}
示例11: populateArtifactsFromDescriptor
import com.google.common.collect.LinkedHashMultimap; //导入方法依赖的package包/类
private void populateArtifactsFromDescriptor() {
Map<Artifact, ModuleComponentArtifactMetaData> artifactToMetaData = Maps.newLinkedHashMap();
for (Artifact descriptorArtifact : getDescriptor().getAllArtifacts()) {
ModuleComponentArtifactMetaData artifact = artifact(descriptorArtifact);
artifactToMetaData.put(descriptorArtifact, artifact);
}
artifacts = Sets.newLinkedHashSet(artifactToMetaData.values());
this.artifactsByConfig = LinkedHashMultimap.create();
for (String configuration : getDescriptor().getConfigurationsNames()) {
Artifact[] configArtifacts = getDescriptor().getArtifacts(configuration);
for (Artifact configArtifact : configArtifacts) {
artifactsByConfig.put(configuration, artifactToMetaData.get(configArtifact));
}
}
}
示例12: validateImportsOf
import com.google.common.collect.LinkedHashMultimap; //导入方法依赖的package包/类
public static LinkedHashMultimap<String, GamlResource> validateImportsOf(final GamlResource resource) {
final TOrderedHashMap<URI, String> uris = allLabeledImportsOf(resource);
uris.remove(GamlResourceServices.properlyEncodedURI(resource.getURI()));
if (!uris.isEmpty()) {
final LinkedHashMultimap<String, GamlResource> imports = LinkedHashMultimap.create();
if (uris.forEachEntry((a, b) -> {
final GamlResource r = (GamlResource) resource.getResourceSet().getResource(a, true);
if (r.hasErrors()) {
resource.invalidate(r, "Errors detected");
return false;
}
imports.put(b, r);
return true;
}))
return imports;
}
return null;
}
示例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());
}
示例14: buildHandCardMultimap
import com.google.common.collect.LinkedHashMultimap; //导入方法依赖的package包/类
private LinkedHashMultimap<Hand, Card> buildHandCardMultimap() {
LinkedHashMultimap<Hand, Card> multimap = LinkedHashMultimap.create();
multimap.put(EAST, CLUB_8);
multimap.put(EAST, SPADE_8);
multimap.put(EAST, DIAMOND_7);
multimap.put(EAST, DIAMOND_8);
multimap.put(SOUTH, CLUB_ACE);
multimap.put(SOUTH, CLUB_KING);
multimap.put(SOUTH, DIAMOND_9);
multimap.put(SOUTH, DIAMOND_10);
multimap.put(WEST, CLUB_JACK);
multimap.put(WEST, CLUB_9);
multimap.put(WEST, HEART_JACK);
multimap.put(WEST, DIAMOND_JACK);
multimap.put(WEST, DIAMOND_QUEEN);
return multimap;
}
示例15: convertToMap
import com.google.common.collect.LinkedHashMultimap; //导入方法依赖的package包/类
private static Multimap<String, Map<String, Object>> convertToMap(Multimap<String, FormValueElement> subElements) {
Multimap<String, Map<String, Object>> elements = LinkedHashMultimap.create();
for (Map.Entry<String, FormValueElement> entry : subElements.entries()) {
Map<String, Object> elementAsMap = new HashMap<>(4); // NO CHECKSTYLE MagicNumber
FormValueElement formValueElement = entry.getValue();
elementAsMap.put(ELEMENT_NAME, formValueElement.getElementName());
elementAsMap.put(SUB_ELEMENTS, convertToMap(formValueElement.getSubElements()));
elementAsMap.put(ATTRIBUTES, formValueElement.getAttributes());
elementAsMap.put(VALUE, formValueElement.getValue());
elements.put(entry.getKey(), elementAsMap);
}
return elements;
}