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

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

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.github.jasonruckman.sidney.ext.guava.MultimapSerializer.java

@Override
public void writeValue(Multimap<K, V> value, Contexts.WriteContext context) {
    Map<K, Collection<V>> map = value.asMap();
    context.getMeta().writeConcreteType(value.getClass());
    context.getMeta().writeRepetitionCount(map.size());
    for (Map.Entry<K, Collection<V>> entry : map.entrySet()) {
        keySerializer.writeValue(entry.getKey(), context);
        context.getMeta().writeRepetitionCount(entry.getValue().size());
        for (V v : entry.getValue()) {
            valueSerializer.writeValue(v, context);
        }//from www.  j  av  a2  s  . c  o m
    }
}

From source file:com.google.devtools.build.lib.skyframe.serialization.MultimapCodec.java

@Override
public void serialize(SerializationContext context, Multimap<K, V> obj, CodedOutputStream codedOut)
        throws SerializationException, IOException {
    if (obj instanceof ListMultimap) {
        codedOut.writeBoolNoTag(true);//from ww w .ja v a 2  s .  c  o m
    } else if (obj instanceof SetMultimap) {
        codedOut.writeBoolNoTag(false);
    } else {
        throw new SerializationException("Unexpected multimap type: " + obj.getClass());
    }
    codedOut.writeInt32NoTag(obj.asMap().size());
    for (Map.Entry<K, Collection<V>> entry : obj.asMap().entrySet()) {
        context.serialize(entry.getKey(), codedOut);
        context.serialize(entry.getValue(), codedOut);
    }
}