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

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

Introduction

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

Prototype

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

Source Link

Document

Returns the runtime class of this Object .

Usage

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

@Override
public void serialize(SerializationContext context, ImmutableMultimap<K, V> obj, CodedOutputStream codedOut)
        throws SerializationException, IOException {
    if (obj instanceof ImmutableListMultimap) {
        codedOut.writeBoolNoTag(true);//from   w w  w . j  av a 2s . c  o m
    } else if (obj instanceof ImmutableSetMultimap) {
        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);
    }
}