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:io.scigraph.services.jersey.MultivaluedMapUtils.java

/***
 * Extracts both the path and query parameters from {@link UriInfo} into a {@link Multimap}
 * //from www .  j ava  2  s  .c  om
 * <p>Path parameters are additionally split on '+' to support multiple values 
 * 
 * @param uriInfo the uriinfo
 * @return the merged multimap
 */
public static Multimap<String, Object> merge(UriInfo uriInfo) {
    Multimap<String, Object> merged = ArrayListMultimap.create();
    merged.putAll(multivaluedMapToMultimap(uriInfo.getPathParameters(), Optional.of('+')));
    merged.putAll(multivaluedMapToMultimap(uriInfo.getQueryParameters()));
    return merged;
}

From source file:com.palantir.common.streams.KeyedStreamImpl.java

private static <K, V> void combine(Multimap<K, V> multimap, Multimap<K, V> entries) {
    multimap.putAll(entries);
}

From source file:org.jclouds.aws.filters.FormSigner.java

private static String buildQueryLine(Multimap<String, String> decodedParams) {
    Multimap<String, String> sortedParams = TreeMultimap.create(actionFirstAccessKeyLast, natural());
    sortedParams.putAll(decodedParams);
    return encodeQueryLine(sortedParams);
}

From source file:uk.ac.ebi.caf.utility.preference.AbstractPreferenceLoader.java

public static Multimap<String, Preference> getCategoryMap(AbstractPreferenceLoader... loaders) {

    List<AbstractPreferenceLoader> loaderList = Arrays.asList(loaders);
    Iterator<AbstractPreferenceLoader> loaderIterator = loaderList.iterator();

    Multimap<String, Preference> map = loaderIterator.next().getCategoryMap();

    while (loaderIterator.hasNext()) {
        map.putAll(loaderIterator.next().getCategoryMap());
    }//w w  w  . j  av a2s .c o  m

    return map;

}

From source file:org.jclouds.http.utils.ModifyRequest.java

@SuppressWarnings("unchecked")
public static <R extends HttpRequest> R putFormParams(R request, Multimap<String, String> params) {
    Multimap<String, String> map = request.getPayload() != null
            ? parseQueryToMap(request.getPayload().getRawContent().toString())
            : LinkedHashMultimap.<String, String>create();
    map.putAll(params);
    return (R) request.toBuilder().payload(newUrlEncodedFormPayload(map)).build();
}

From source file:org.apache.calcite.rel.metadata.RelMdNodeTypes.java

private static Multimap<Class<? extends RelNode>, RelNode> getNodeTypes(RelNode rel, Class<? extends RelNode> c,
        RelMetadataQuery mq) {//from  w w  w  .  j  a  v  a2 s  .c om
    final Multimap<Class<? extends RelNode>, RelNode> nodeTypeCount = ArrayListMultimap.create();
    for (RelNode input : rel.getInputs()) {
        Multimap<Class<? extends RelNode>, RelNode> partialNodeTypeCount = mq.getNodeTypes(input);
        if (partialNodeTypeCount == null) {
            return null;
        }
        nodeTypeCount.putAll(partialNodeTypeCount);
    }
    nodeTypeCount.put(c, rel);
    return nodeTypeCount;
}

From source file:grakn.core.graql.reasoner.utils.ReasonerUtils.java

/**
 * NB: assumes MATCH semantics - all types and their subs are considered
 * compute the map of compatible {@link RelationType}s for a given set of {@link Type}s
 * (intersection of allowed sets of relation types for each entry type) and compatible role types
 * @param types for which the set of compatible {@link RelationType}s is to be computed
 * @param schemaConceptConverter converter between {@link SchemaConcept} and relation type-role entries
 * @param <T> type generic/*from   www .j  a  v a 2 s. co  m*/
 * @return map of compatible {@link RelationType}s and their corresponding {@link Role}s
 */
public static <T extends SchemaConcept> Multimap<RelationType, Role> compatibleRelationTypesWithRoles(
        Set<T> types, SchemaConceptConverter<T> schemaConceptConverter) {
    Multimap<RelationType, Role> compatibleTypes = HashMultimap.create();
    if (types.isEmpty())
        return compatibleTypes;
    Iterator<T> typeIterator = types.iterator();
    compatibleTypes.putAll(schemaConceptConverter.toRelationMultimap(typeIterator.next()));

    while (typeIterator.hasNext() && compatibleTypes.size() > 1) {
        compatibleTypes = multimapIntersection(compatibleTypes,
                schemaConceptConverter.toRelationMultimap(typeIterator.next()));
    }
    return compatibleTypes;
}

From source file:ai.grakn.graql.internal.reasoner.utils.ReasonerUtils.java

/**
 * compute the map of compatible relation types for given types (intersection of allowed sets of relation types for each entry type)
 * and compatible role types//from w w w . ja v a  2  s. c  om
 * @param types for which the set of compatible relation types is to be computed
 //* @param typeMapper function mapping a type to the set of compatible relation types
 * @param <T> type generic
 * @return map of compatible relation types and their corresponding role types
 */
public static <T extends Type> Multimap<RelationType, RoleType> getCompatibleRelationTypesWithRoles(
        Set<T> types, TypeConverter<T> typeConverter) {
    Multimap<RelationType, RoleType> compatibleTypes = HashMultimap.create();
    if (types.isEmpty())
        return compatibleTypes;
    Iterator<T> it = types.iterator();
    compatibleTypes.putAll(typeConverter.toRelationMultimap(it.next()));
    while (it.hasNext() && compatibleTypes.size() > 1) {
        compatibleTypes = multimapIntersection(compatibleTypes, typeConverter.toRelationMultimap(it.next()));
    }
    return compatibleTypes;
}

From source file:com.google.devtools.build.lib.analysis.ExtraActionUtils.java

/**
 * Populates the configuration specific mnemonicToExtraActionMap
 * based on all action_listers selected by the user (via the blaze option
 * {@code --experimental_action_listener=<target>}).
 *///  ww w .  j a v a2  s  .c  o m
private static Multimap<String, ExtraActionSpec> computeMnemonicsToExtraActionMap(RuleContext ruleContext) {
    // We copy the multimap here every time. This could be expensive.
    Multimap<String, ExtraActionSpec> mnemonicToExtraActionMap = HashMultimap.create();
    for (TransitiveInfoCollection actionListener : ruleContext.getPrerequisites(":action_listener",
            Mode.HOST)) {
        ExtraActionMapProvider provider = actionListener.getProvider(ExtraActionMapProvider.class);
        if (provider == null) {
            ruleContext.ruleError(String.format(
                    "Unable to match experimental_action_listeners to this rule. "
                            + "Specified target %s is not an action_listener rule",
                    actionListener.getLabel().toString()));
        } else {
            mnemonicToExtraActionMap.putAll(provider.getExtraActionMap());
        }
    }
    return mnemonicToExtraActionMap;
}

From source file:org.sosy_lab.cpachecker.util.predicates.matching.SmtAstMatchResultImpl.java

@Override
public void appendBindingsTo(Multimap<String, Formula> pTarget) {
    pTarget.putAll(variableBindings);
}