Example usage for com.google.common.collect Multimap putAll

List of usage examples for com.google.common.collect Multimap putAll

Introduction

In this page you can find the example usage for com.google.common.collect Multimap putAll.

Prototype

boolean putAll(Multimap<? extends K, ? extends V> multimap);

Source Link

Document

Stores all key-value pairs of multimap in this multimap, in the order returned by multimap.entries() .

Usage

From source file:edu.buaa.satla.analysis.core.predicate.PredicatePrecision.java

/**
 * Create a new precision which contains all predicates of this precision
 * and a second one./*  www .j  a  va2s .c o m*/
 */
public PredicatePrecision mergeWith(PredicatePrecision prec) {
    // create new set of global predicates
    Collection<AbstractionPredicate> newGlobalPredicates = Lists.newArrayList(getGlobalPredicates());
    newGlobalPredicates.addAll(prec.getGlobalPredicates());
    newGlobalPredicates = ImmutableSet.copyOf(newGlobalPredicates);

    // create new multimap of function-specific predicates
    Multimap<String, AbstractionPredicate> newFunctionPredicates = ArrayListMultimap
            .create(getFunctionPredicates());
    newFunctionPredicates.putAll(prec.getFunctionPredicates());

    if (!newGlobalPredicates.isEmpty()) {
        for (String function : newFunctionPredicates.keySet()) {
            newFunctionPredicates.putAll(function, newGlobalPredicates);
        }
    }
    newFunctionPredicates = ImmutableSetMultimap.copyOf(newFunctionPredicates);

    // create new multimap of location-specific predicates
    Multimap<CFANode, AbstractionPredicate> newLocalPredicates = ArrayListMultimap.create(getLocalPredicates());
    newLocalPredicates.putAll(prec.getLocalPredicates());

    if (!newGlobalPredicates.isEmpty() || !newFunctionPredicates.isEmpty()) {
        for (CFANode loc : newLocalPredicates.keySet()) {
            newLocalPredicates.putAll(loc, newGlobalPredicates);
            newLocalPredicates.putAll(loc, newFunctionPredicates.get(loc.getFunctionName()));
        }
    }

    // create new multimap of location-instance-specific predicates
    Multimap<Pair<CFANode, Integer>, AbstractionPredicate> newLocationInstanceSpecificPredicates = ArrayListMultimap
            .create(getLocationInstancePredicates());
    newLocationInstanceSpecificPredicates.putAll(prec.getLocationInstancePredicates());

    if (!newGlobalPredicates.isEmpty() || !newFunctionPredicates.isEmpty() || !newLocalPredicates.isEmpty()) {
        for (Pair<CFANode, Integer> key : newLocationInstanceSpecificPredicates.keySet()) {
            newLocationInstanceSpecificPredicates.putAll(key, newGlobalPredicates);
            newLocationInstanceSpecificPredicates.putAll(key,
                    newFunctionPredicates.get(key.getFirst().getFunctionName()));
            newLocationInstanceSpecificPredicates.putAll(key, newLocalPredicates.get(key.getFirst()));
        }
    }

    return new PredicatePrecision(newLocationInstanceSpecificPredicates, newLocalPredicates,
            newFunctionPredicates, newGlobalPredicates);
}

From source file:org.semanticweb.owlapi.search.EntitySearcher.java

/**
 * @param i individual//  www  .  j av a 2  s  .c o  m
 * @param ontologies ontologies to search
 * @return literal values
 */
public static Multimap<OWLDataPropertyExpression, OWLLiteral> getDataPropertyValues(OWLIndividual i,
        Stream<OWLOntology> ontologies) {
    Multimap<OWLDataPropertyExpression, OWLLiteral> map = LinkedListMultimap.create();
    ontologies.forEach(o -> map.putAll(getDataPropertyValues(i, o)));
    return map;
}

From source file:org.semanticweb.owlapi.search.EntitySearcher.java

/**
 * @param i individual/*from   www.j av a  2s . c o  m*/
 * @param ontologies ontologies to search
 * @return property values
 */
public static Multimap<OWLDataPropertyExpression, OWLLiteral> getNegativeDataPropertyValues(OWLIndividual i,
        Stream<OWLOntology> ontologies) {
    Multimap<OWLDataPropertyExpression, OWLLiteral> map = LinkedListMultimap.create();
    ontologies.forEach(o -> map.putAll(getNegativeDataPropertyValues(i, o)));
    return map;
}

From source file:org.semanticweb.owlapi.search.EntitySearcher.java

/**
 * @param i individual/*from   ww w. j a v  a 2  s  .c  o m*/
 * @param ontologies ontologies to search
 * @return property values
 */
public static Multimap<OWLObjectPropertyExpression, OWLIndividual> getObjectPropertyValues(OWLIndividual i,
        Stream<OWLOntology> ontologies) {
    Multimap<OWLObjectPropertyExpression, OWLIndividual> map = LinkedListMultimap.create();
    ontologies.forEach(o -> map.putAll(getObjectPropertyValues(i, o)));
    return map;
}

From source file:org.semanticweb.owlapi.search.EntitySearcher.java

/**
 * @param i individual//from  w  w  w  . j av  a 2  s  . c  om
 * @param ontologies ontologies to search
 * @return property values
 */
public static Multimap<OWLObjectPropertyExpression, OWLIndividual> getNegativeObjectPropertyValues(
        OWLIndividual i, Stream<OWLOntology> ontologies) {
    Multimap<OWLObjectPropertyExpression, OWLIndividual> map = LinkedListMultimap.create();
    ontologies.forEach(o -> map.putAll(getNegativeObjectPropertyValues(i, o)));
    return map;
}

From source file:org.glowroot.local.ui.ClasspathCache.java

synchronized void updateCache() {
    Multimap<String, File> newClassNameLocations = HashMultimap.create();
    for (ClassLoader loader : getKnownClassLoaders()) {
        updateCache(loader, newClassNameLocations);
    }/*from   w w  w. j  ava  2s .c om*/
    updateCacheWithBootstrapClasses(newClassNameLocations);
    if (!newClassNameLocations.isEmpty()) {
        Multimap<String, File> newMap = TreeMultimap.create(String.CASE_INSENSITIVE_ORDER, Ordering.natural());
        newMap.putAll(classNameLocations);
        newMap.putAll(newClassNameLocations);
        classNameLocations = ImmutableMultimap.copyOf(newMap);
    }
}

From source file:org.eclipse.xtext.mwe.Validator.java

protected Multimap<URI, MWEDiagnostic> groupByURI(MWEDiagnostic[] diagnostic) {
    Multimap<URI, MWEDiagnostic> result = Multimaps.newMultimap(
            Maps.<URI, Collection<MWEDiagnostic>>newLinkedHashMap(), new Supplier<Collection<MWEDiagnostic>>() {
                @Override/*w w  w  . j  a  v  a  2 s.co m*/
                public Collection<MWEDiagnostic> get() {
                    return Sets.newTreeSet(getDiagnosticComparator());
                }
            });
    result.putAll(Multimaps.index(Arrays.asList(diagnostic), new Function<MWEDiagnostic, URI>() {
        @Override
        public URI apply(MWEDiagnostic from) {
            Issue issue = (Issue) from.getElement();
            URI uriToProblem = issue.getUriToProblem();
            return uriToProblem != null ? uriToProblem.trimFragment() : NullURI;
        }
    }));
    return result;
}

From source file:com.google.devtools.build.lib.query2.output.PreciseAspectResolver.java

@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;//  w w w.  j a  v  a2  s.co  m
            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);
}

From source file:org.mqnaas.core.impl.ApplicationInstance.java

public Multimap<Class<? extends IApplication>, IService> getServices() {
    Multimap<Class<? extends IApplication>, IInternalService> internalServices = proxyHolder.getServices();
    Multimap<Class<? extends IApplication>, IService> services = ArrayListMultimap
            .create(internalServices.size(), 3);
    services.putAll(internalServices);
    return services;
}

From source file:com.github.haixing_hu.lang.Assignment.java

public static <K, V> Multimap<K, V> assign(@Nullable Multimap<K, V> left,
        @Nullable final Multimap<K, V> right) {
    if (right == null) {
        if (left != null) {
            left.clear();//from   w w w  .jav a2s. c  o  m
        }
    } else {
        if (left == null) {
            left = LinkedHashMultimap.create();
        } else {
            left.clear();
        }
        left.putAll(right);
    }
    return left;
}