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

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

Introduction

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

Prototype

boolean put(@Nullable K key, @Nullable V value);

Source Link

Document

Stores a key-value pair in this multimap.

Usage

From source file:org.apache.abdera2.examples.uritemplates.URITemplates.java

private static void exampleWithMap() {
    Multimap<String, Object> map = LinkedHashMultimap.create();
    map.put("user", "james");
    map.put("categories", "a");
    map.put("categories", "b");
    map.put("categories", "c");
    map.put("foo", "abc");
    map.put("bar", "xyz");
    System.out.println(template.expand(map));
}

From source file:com.spectralogic.ds3client.commands.interfaces.AbstractRequest.java

private static Multimap<String, String> buildDefaultHeaders() {
    final Multimap<String, String> headers = TreeMultimap.create();
    headers.put("Naming-Convention", "s3");
    return headers;
}

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

private static <K, V> void accumulate(Multimap<K, V> multimap, Map.Entry<K, V> entry) {
    multimap.put(entry.getKey(), entry.getValue());
}

From source file:com.github.drbookings.model.data.BookingMapFactory.java

public static Multimap<BookingBean, BookingEntry> buildMap(Collection<? extends BookingEntry> entries) {

    Multimap<BookingBean, BookingEntry> result = ArrayListMultimap.create();

    for (BookingEntry be : entries) {
        result.put(be.getElement(), be);
    }/*  ww w.ja v  a2  s.c  o  m*/

    return result;
}

From source file:org.apache.beam.runners.core.InMemoryMultimapSideInputView.java

/**
 * Creates a {@link MultimapView} from the provided values. The provided {@link Coder} is used to
 * guarantee structural equality for keys instead of assuming Java object equality.
 *//*from  w  w w . j a  va2s . c o  m*/
public static <K, V> MultimapView<K, V> fromIterable(Coder<K> keyCoder, Iterable<KV<K, V>> values) {
    // We specifically use an array list multimap to allow for:
    //  * null keys
    //  * null values
    //  * duplicate values
    Multimap<Object, Object> multimap = ArrayListMultimap.create();
    for (KV<K, V> value : values) {
        multimap.put(keyCoder.structuralValue(value.getKey()), value.getValue());
    }
    return new InMemoryMultimapSideInputView(keyCoder, Multimaps.unmodifiableMultimap(multimap));
}

From source file:exm.stc.common.util.Misc.java

public static void putAllMultimap(Multimap<String, Type> dst, Map<String, Type> src) {
    for (Entry<String, Type> e : src.entrySet()) {
        dst.put(e.getKey(), e.getValue());
    }/*from w  w  w  .ja va 2s .  c om*/
}

From source file:com.yahoo.yqlplus.engine.tools.TraceFormatter.java

public static void dump(OutputStream outputStream, TraceRequest trace) throws IOException {
    Multimap<Integer, TraceEntry> childmap = ArrayListMultimap.create();
    for (TraceEntry entry : trace.getEntries()) {
        childmap.put(entry.getParentId(), entry);
    }//from   w  ww. ja v a  2  s.co m
    Multimap<Integer, TraceLogEntry> logmap = ArrayListMultimap.create();
    for (TraceLogEntry entry : trace.getLog()) {
        logmap.put(entry.getTraceId(), entry);
    }

    CodeOutput out = new CodeOutput();
    dumpTree(out, childmap, logmap, childmap.get(0));
    outputStream.write(out.toString().getBytes(StandardCharsets.UTF_8));
}

From source file:com.zimbra.soap.account.type.Pref.java

public static Multimap<String, String> toMultimap(Iterable<Pref> prefs) {
    Multimap<String, String> map = ArrayListMultimap.create();
    for (Pref p : prefs) {
        map.put(p.getName(), p.getValue());
    }//w w  w  .jav a2s . co m
    return map;
}

From source file:org.polarsys.reqcycle.traceability.utils.EngineUtils.java

public static Multimap<Reachable, Link> toPrecedingMap(Iterator<Pair<Link, Reachable>> resultOfEngine) {
    Multimap<Reachable, Link> result = HashMultimap.create();
    while (resultOfEngine.hasNext()) {
        Pair<Link, Reachable> next = resultOfEngine.next();
        result.put(next.getFirst().getTargets().iterator().next(), next.getFirst());
    }//from   w w w . ja  v a2 s  . co m
    return result;
}

From source file:hellfirepvp.astralsorcery.common.util.SwordSharpenHelper.java

public static void applySharpenModifier(@Nonnull ItemStack stack, EntityEquipmentSlot slot,
        Multimap<String, AttributeModifier> map) {
    if (isSwordSharpened(stack) && slot.equals(EntityEquipmentSlot.MAINHAND)) {
        map.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), MODIFIER_SHARPENED);
    }/*from ww  w . j a v a 2s . c  om*/
}