Example usage for com.google.common.collect ClassToInstanceMap get

List of usage examples for com.google.common.collect ClassToInstanceMap get

Introduction

In this page you can find the example usage for com.google.common.collect ClassToInstanceMap get.

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:org.obm.push.utils.collection.ClassToInstanceAgregateView.java

@SuppressWarnings("unchecked")
public <T> T get(Class<T> key) {
    T result = null;/*from  w w w . j  a  va2  s. c  o  m*/
    for (ClassToInstanceMap<V> map : maps) {
        V value = map.get(key);
        if (value != null) {
            if (result != null) {
                throw new IllegalStateException("type " + key + " is registered in several maps");
            }
            result = (T) value;
        }
    }
    return result;
}

From source file:com.google.errorprone.bugpatterns.collectionincompatibletype.CollectionIncompatibleTypeNegativeCases.java

public <T extends String> T subclassHasDifferentTypeParameters(ClassToInstanceMap<String> map, Class<T> klass) {
    return klass.cast(map.get(klass));
}

From source file:com.google.errorprone.bugpatterns.collectionincompatibletype.CollectionIncompatibleTypePositiveCases.java

public String subclassHasDifferentTypeParameters(ClassToInstanceMap<String> map, String s) {
    // BUG: Diagnostic contains:
    return map.get(s);
}