Example usage for com.google.common.collect HashMultimap create

List of usage examples for com.google.common.collect HashMultimap create

Introduction

In this page you can find the example usage for com.google.common.collect HashMultimap create.

Prototype

public static <K, V> HashMultimap<K, V> create() 

Source Link

Document

Creates a new, empty HashMultimap with the default initial capacities.

Usage

From source file:eu.esdihumboldt.hale.ui.common.graph.content.NestedCellRelationshipContentProvider.java

/**
 * @see CellRelationshipContentProvider#getElements(Object)
 *//*  ww  w  .j  a  v a  2s.  c  o  m*/
@Override
public Object[] getElements(Object input) {
    List<Object> elements = new ArrayList<Object>();

    entityMap.clear();

    Multimap<TypeDefinition, Type> types = HashMultimap.create();
    Collection<Property> properties = new ArrayList<Property>();

    for (Object element : super.getElements(input)) {
        if (element instanceof Type) {
            Type type = (Type) element;
            types.put(type.getDefinition().getDefinition(), type);
            elements.add(element);
        } else if (element instanceof Property) {
            properties.add((Property) element);
        } else {
            elements.add(element);
        }
    }

    // assign properties to corresponding parents
    for (Property property : properties) {
        // find association through type definition
        TypeDefinition parentType = property.getDefinition().getType();
        Collection<Type> typeList = types.get(parentType);
        for (Type type : typeList) {
            entityMap.put(type, property);
        }
    }

    return elements.toArray();
}

From source file:org.summer.dsl.xbase.typesystem.override.ParameterizedResolvedFeatures.java

protected List<JvmFeature> computeAllFeatures(List<JvmFeature> unfiltered) {
    List<JvmFeature> result = Lists.newArrayListWithExpectedSize(unfiltered.size());
    Multimap<String, AbstractResolvedOperation> processed = HashMultimap.create();
    computeAllFeatures(unfiltered, processed, result);
    return Collections.unmodifiableList(result);
}

From source file:suneido.SuRecord.java

public SuRecord() {
    hdr = null;
    tran = null;
    recadr = 0;
    status = Status.NEW;
    invalid = Sets.newHashSet();
    dependencies = HashMultimap.create();
}

From source file:edu.cmu.lti.oaqa.baseqa.answer.score.scorers.ConceptTypeAnswerScorer.java

@Override
public void prepare(JCas jcas) throws AnalysisEngineProcessException {
    offset2ctypes = HashMultimap.create();
    for (Concept concept : TypeUtil.getConcepts(jcas)) {
        Set<String> ctypes = TypeUtil.getConceptTypes(concept).stream().map(ConceptType::getAbbreviation)
                .collect(toSet());//  w w w.  j a v  a 2  s.  c  o m
        for (ConceptMention cmention : TypeUtil.getConceptMentions(concept))
            offset2ctypes.putAll(TypeUtil.annotationOffset(cmention), ctypes);
    }
}

From source file:fr.inria.maestro.lga.clustering.impl.ClusteringBuilder.java

/**
 * Creates the empty classification./* w  w  w  .  j a v a  2 s .c  o m*/
 * @param clusteringName - the name of classification
 */
public ClusteringBuilder(final String clusteringName) {
    this.clusteringName = clusteringName;
    this.clustersNamesList = Lists.newArrayList();
    this.clustersNamesSet = Sets.newHashSet();
    this.cluster2Entries = HashMultimap.create();
    this.cluster2PropertiesHolder = Maps.newHashMap();
}

From source file:org.sonar.java.filters.BaseTreeVisitorIssueFilter.java

public BaseTreeVisitorIssueFilter() {
    excludedLinesByRule = HashMultimap.create();
    rulesKeysByRulesClass = rulesKeysByRulesClass(filteredRules());
}

From source file:org.eclipse.gef4.mvc.examples.logo.rcp.parts.FXGeometricModelPart.java

@Override
protected SetMultimap<? extends Object, String> doGetContentAnchorages() {
    return HashMultimap.create();
}

From source file:com.facebook.buck.core.util.graph.MutableDirectedGraph.java

public static <T> MutableDirectedGraph<T> createConcurrent() {
    return new MutableDirectedGraph<>(Collections.newSetFromMap(new ConcurrentHashMap<T, Boolean>()),
            Multimaps.synchronizedSetMultimap(HashMultimap.create()),
            Multimaps.synchronizedSetMultimap(HashMultimap.create()));
}

From source file:com.github.naios.wide.framework.internal.storage.server.builder.SQLScope.java

/**
 * Splits collections containing update, insert & delete structures into its scopes
 *//*from  w  ww . jav  a2  s . c om*/
protected static Map<String, SQLScope> split(final SQLBuilderImpl sqlBuilder,
        final Map<ServerStorageStructure, Collection<SQLUpdateInfo>> update,
        final Collection<ServerStorageStructure> insert, final Collection<ServerStorageStructure> delete) {
    final Map<String, SQLScope> scopes = new HashMap<>();

    update.forEach((structure, infos) -> {
        infos.forEach(new SQLScopeSplitter<SQLUpdateInfo>(scopes) {
            @Override
            public SQLBuilderImpl getSQLBuilder() {
                return sqlBuilder;
            }

            @Override
            public String getScope(final SQLUpdateInfo info) {
                return sqlBuilder.getSQLInfoProvider().getScopeOfEntry(structure, info.getProperty());
            }

            @Override
            public void addObservable(final SQLScope scope, final SQLUpdateInfo info) {
                Multimap<ServerStorageStructure, SQLUpdateInfo> map = scope.update.get(structure.getOwner());
                if (Objects.isNull(map)) {
                    map = HashMultimap.create();
                    scope.update.put(structure.getOwner(), map);
                }

                map.put(structure, info);
            }
        });
    });

    insert.forEach(new SQLScopeSplitter<ServerStorageStructure>(scopes) {
        @Override
        public SQLBuilderImpl getSQLBuilder() {
            return sqlBuilder;
        }

        @Override
        public String getScope(final ServerStorageStructure entry) {
            return sqlBuilder.getSQLInfoProvider().getScopeOfStructure(entry);
        }

        @Override
        public void addObservable(final SQLScope scope, final ServerStorageStructure entry) {
            scope.insert.put(entry.getOwner(), entry);
        }
    });

    delete.forEach(new SQLScopeSplitter<ServerStorageStructure>(scopes) {
        @Override
        public SQLBuilderImpl getSQLBuilder() {
            return sqlBuilder;
        }

        @Override
        public String getScope(final ServerStorageStructure entry) {
            return sqlBuilder.getSQLInfoProvider().getScopeOfStructure(entry);
        }

        @Override
        public void addObservable(final SQLScope scope, final ServerStorageStructure entry) {
            scope.delete.put(entry.getOwner(), entry);
        }
    });

    return scopes;
}

From source file:edu.sdsc.solr.lemmatization.LemmatizationWriter.java

Multimap<String, String> buildSynonymMap() throws IOException {
    final Multimap<String, String> synonyms = HashMultimap.create();
    synonyms.putAll(spec.getExtraSynonyms());

    Files.readLines(uncompressedDictionary, Charsets.UTF_8, new LineProcessor<Void>() {

        @Override/* www.j  a v a 2  s. c om*/
        public boolean processLine(String line) throws IOException {
            List<String> cols = newArrayList(Splitter.on('\t').split(line));
            String language = cols.get(0);
            if (!spec.getLanguages().contains(language)) {
                return true;
            }
            Optional<String> synonym = DefinitionParser.getSynonym(cols.get(3), spec);
            if (synonym.isPresent()) {
                synonyms.put(synonym.get(), cols.get(1).trim());
            }
            return true;
        }

        @Override
        public Void getResult() {
            return null;
        }
    });
    return synonyms;
}