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

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

Introduction

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

Prototype

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

Source Link

Document

Constructs a LinkedListMultimap with the same mappings as the specified Multimap .

Usage

From source file:com.lmax.nanofix.incoming.FixMessage.java

public FixMessage(final Multimap<Integer, String> multimap) {
    this.multimap = LinkedListMultimap.create(multimap);
}

From source file:com.isotrol.impe3.freemarker.wrap.ModelUtils.java

static Multimap<String, String> buildURIQueryParameters(List<String> args, int index) {
    if (args == null || (args.size() - index) < 2) {
        return ImmutableMultimap.of();
    }/*w w  w  .j a v a  2  s  .  co m*/
    final int n = args.size();
    final Multimap<String, String> map = LinkedListMultimap.create(n / 2);
    for (int i = index; (args.size() - i) >= 2; i += 2) {
        String p = args.get(i);
        String v = args.get(i + 1);
        if (p != null && v != null) {
            map.put(p, v);
        }
    }
    return map;
}

From source file:org.invenzzia.helium.domain.relation.Relationship.java

public Relationship(MetaRelationship info, int expectedKeys) {
    super(info);/*from w w w . ja  va 2  s.  c o m*/
    this.relationship = LinkedListMultimap.create(expectedKeys);
    this.inverseRelationship = new LinkedHashMap<>(expectedKeys);
}

From source file:com.amediamanager.metrics.MetricBatcher.java

@Scheduled(fixedDelay = 60000)
private void send() {
    LOG.info("Sending metric data.");
    synchronized (queuedDatums) {
        sendBatch(LinkedListMultimap.create(queuedDatums).asMap());
        queuedDatums.clear();/*from  www. j  a  v a2 s .c  om*/
    }
}

From source file:com.tinspx.util.net.RequestBody.java

public static RequestBody of(ByteSource source, String... headers) {
    checkArgument(headers.length % 2 == 0, "headers list is odd (%s)", headers.length);
    Multimap<String, String> map = LinkedListMultimap.create(headers.length / 2);
    for (int i = 0; i < headers.length; i += 2) {
        map.put(headers[i], headers[i + 1]);
    }//w ww .  ja v  a 2  s  . c o m
    return of(source, map, false);
}

From source file:com.isotrol.impe3.freemarker.wrap.URIBuilderModel.java

private Multimap<String, String> merge(List<String> args) {
    Multimap<String, String> extra = buildURIQueryParameters(args, 0);
    if (extra.isEmpty()) {
        return parameters;
    }/*from   w  w  w .jav a  2s .  c o m*/
    Multimap<String, String> total = LinkedListMultimap.create(parameters);
    total.putAll(extra);
    return total;
}

From source file:com.tinspx.util.net.RequestBody.java

static <K, V> LinkedListMultimap<K, V> copyOf(Map<? extends K, ? extends Iterable<? extends V>> headers) {
    LinkedListMultimap<K, V> map = LinkedListMultimap.create(headers.size());
    for (Map.Entry<? extends K, ? extends Iterable<? extends V>> entry : headers.entrySet()) {
        map.putAll(entry.getKey(), entry.getValue());
    }//from  w  ww .  j  a v  a  2  s  . c  o  m
    return map;
}

From source file:org.eclipse.gemoc.execution.concurrent.ccsljavaengine.eventscheduling.trace.GCopier.java

@Override
protected void copyAttribute(EAttribute eAttribute, EObject eObject, EObject copyEObject) {
    if (eObject.eIsSet(eAttribute)) {
        if (FeatureMapUtil.isFeatureMap(eAttribute)) {
            FeatureMap featureMap = (FeatureMap) eObject.eGet(eAttribute);
            for (int i = 0, size = featureMap.size(); i < size; ++i) {
                EStructuralFeature feature = featureMap.getEStructuralFeature(i);
                if (feature instanceof EReference && ((EReference) feature).isContainment()) {
                    Object value = featureMap.getValue(i);
                    if (value != null) {
                        copy((EObject) value);
                    }// w w w.ja va2 s.co m
                }
            }
        } else if (eAttribute.isMany()) {
            List<?> source = (List<?>) eObject.eGet(eAttribute);
            @SuppressWarnings("unchecked")
            List<Object> target = (List<Object>) copyEObject.eGet(getTarget(eAttribute));
            if (source.isEmpty()) {
                target.clear();
            } else {
                target.addAll(source);
            }
        } else {
            Object value = eObject.eGet(eAttribute);
            Object newValue = value;
            // [FT] todo add more specific cases.
            if (value instanceof LinkedListMultimap) {
                LinkedListMultimap<?, ?> tempValue = LinkedListMultimap.create((LinkedListMultimap) value);
                newValue = tempValue;
            } else if (value instanceof ArrayList<?>) {
                ArrayList<?> tempValue = new ArrayList((ArrayList) value);
                newValue = tempValue;
            }
            copyEObject.eSet(getTarget(eAttribute), newValue);
        }
    }
}

From source file:com.google.devtools.moe.client.repositories.MetadataScrubber.java

/**
 * A utility method that is useful for stripping a list of words from all the fields of the
 * RevisionMetadata.//from w  ww.jav a 2s. com
 *
 * @param rm the RevisionMetadata to scrub
 * @param words the list of words to replace
 * @param replacement the String to replace the target words with
 * @param wordAlone true if the words to match must surrounded by word boundaries
 * @return a copy representing the RevisionMetadata resulting from the scrub
 */
public static RevisionMetadata stripFromAllFields(RevisionMetadata rm, List<String> words, String replacement,
        boolean wordAlone) {

    String newId = rm.id();
    String newAuthor = rm.author();
    String newDescription = rm.description();
    ListMultimap<String, String> newFields = LinkedListMultimap.create(rm.fields());
    for (String word : words) {
        String regex = (wordAlone) ? ("(?i)(\\b)" + word + "(\\b)") : ("(?i)" + word);
        newId = newId.replaceAll(regex, replacement);
        newAuthor = replaceAuthor(newAuthor, word, replacement);
        newDescription = newDescription.replaceAll(regex, replacement);
        for (Entry<String, String> entry : newFields.entries()) {
            entry.setValue(entry.getValue().replaceAll(regex, replacement));
        }
    }
    return rm.toBuilder().id(newId).author(newAuthor).description(newDescription)
            .fields(ImmutableSetMultimap.copyOf(newFields)).build();
}

From source file:com.tinspx.util.net.RequestBody.java

static <K, V> LinkedListMultimap<K, V> copyOfMap(Map<? extends K, ? extends V> headers) {
    LinkedListMultimap<K, V> map = LinkedListMultimap.create(headers.size());
    for (Map.Entry<? extends K, ? extends V> entry : headers.entrySet()) {
        map.put(entry.getKey(), entry.getValue());
    }//  ww w.j ava 2 s . c  om
    return map;
}