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

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

Introduction

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

Prototype

public static <K, V> LinkedHashMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) 

Source Link

Document

Constructs a LinkedHashMultimap with the same mappings as the specified multimap.

Usage

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

@SuppressWarnings("unchecked")
public static <R extends HttpRequest> R replaceHeaders(R request, Multimap<String, String> headers) {
    Multimap<String, String> newHeaders = LinkedHashMultimap
            .create(checkNotNull(request, "request").getHeaders());
    for (String header : headers.keySet())
        newHeaders.replaceValues(header, headers.get(header));
    return (R) request.toBuilder().headers(newHeaders).build();
}

From source file:com.addthis.basis.util.Multidict.java

public Multidict(Multidict copyme) {
    assert (copyme != null);
    this.map = LinkedHashMultimap.create(copyme.map);
}

From source file:io.wcm.caravan.io.http.response.CaravanHttpResponse.java

CaravanHttpResponse(int status, String reason, Multimap<String, String> headers, Body body) {
    checkState(status >= 200, "Invalid status code: %s", status);
    this.status = status;
    this.reason = checkNotNull(reason, "reason");
    Multimap<String, String> copyOf = LinkedHashMultimap.create(checkNotNull(headers, "headers"));
    this.headers = ImmutableMultimap.copyOf(copyOf);
    this.body = body; // nullable
}

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

@SuppressWarnings("unchecked")
public static <R extends HttpRequest> R replaceHeader(R request, String header, Iterable<String> values) {
    Multimap<String, String> headers = LinkedHashMultimap.create(checkNotNull(request, "request").getHeaders());
    headers.replaceValues(checkNotNull(header, "header"), checkNotNull(values, "values"));
    return (R) request.toBuilder().headers(headers).build();
}

From source file:com.github.rinde.rinsim.geom.MultimapGraph.java

/**
 * Instantiates a new graph using the specified multimap.
 * @param map The multimap that is copied into this new graph.
 *///from   ww w  .  j  ava2  s. c o m
public MultimapGraph(Multimap<Point, Point> map) {
    multimap = LinkedHashMultimap.create(map);
    lazyConnectionTable = Tables.newCustomTable(new LinkedHashMap<Point, Map<Point, Connection<E>>>(),
            new LinkedHashMapFactory<Connection<E>>());
    deadEndNodes = new HashSet<>();
    deadEndNodes.addAll(multimap.values());
    deadEndNodes.removeAll(multimap.keySet());
}

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

@SuppressWarnings("unchecked")
public static <R extends HttpRequest> R removeHeader(R request, String header) {
    Multimap<String, String> headers = LinkedHashMultimap.create(checkNotNull(request, "request").getHeaders());
    headers.removeAll(checkNotNull(header, "header"));
    return (R) request.toBuilder().headers(headers).build();
}

From source file:io.wcm.caravan.io.http.request.CaravanHttpRequest.java

/**
 * @param serviceId Logical name of the request service. Used by {@link CaravanHttpClient} to resolve the real URL.
 *          If null, only {@code url} is used
 * @param method HTTP method verb// ww  w  .  j  av  a2  s.  c  om
 * @param url Service request URL. Can be an absolute URL or just an path getting combined with the URL of the logical
 *          service ID
 * @param headers HTTP headers
 * @param body HTTP Payload
 * @param charset Payload charset
 */
CaravanHttpRequest(final String serviceId, final String method, final String url,
        final Multimap<String, String> headers, final byte[] body, final Charset charset) {
    this.serviceId = serviceId; // nullable
    this.method = checkNotNull(method, "method of %s", url);
    this.url = checkNotNull(url, "url");
    this.headers = ImmutableMultimap
            .copyOf(LinkedHashMultimap.create(checkNotNull(headers, "headers of %s %s", method, url)));
    this.body = body; // nullable
    this.charset = charset; // nullable
    this.performanceMetrics = PerformanceMetrics
            .createNew(StringUtils.defaultString(serviceId, "UNKNOWN SERVICE") + " : "
                    + StringUtils.defaultString(method, "UNKNOWN METHOD"), url, getCorrelationId());
}

From source file:com.viadeo.kasper.common.exposition.query.QueryParser.java

public QueryParser(final SetMultimap<String, String> queryMap) {
    this.queryMap = LinkedHashMultimap.create(queryMap);
}

From source file:org.lanternpowered.server.profile.LanternGameProfile.java

/**
 * Creates a copy of this game profile./*from w ww . java  2  s .  c  om*/
 *
 * @return The copy
 */
public LanternGameProfile copy() {
    return new LanternGameProfile(this.uniqueId, this.name, LinkedHashMultimap.create(this.properties));
}

From source file:org.smartdeveloperhub.curator.connector.Constraints.java

/**
 * Copy-on-write/*from   ww w .  j ava  2s. c  o  m*/
 */
private void add(final NamedValue target, final URI property, final Value value) {
    this.bindings = LinkedHashMultimap.create(this.bindings);
    this.bindings.put(target, ProtocolFactory.newBinding().withProperty(property).withValue(value).build());
}