Package com.google.common.collect
Class ImmutableClassToInstanceMap<B>
- java.lang.Object
 - 
- com.google.common.collect.ForwardingObject
 - 
- com.google.common.collect.ForwardingMap<java.lang.Class<? extends B>,B>
 - 
- com.google.common.collect.ImmutableClassToInstanceMap<B>
 
 
 
 
- 
- All Implemented Interfaces:
 ClassToInstanceMap<B>,java.util.Map<java.lang.Class<? extends B>,B>
public final class ImmutableClassToInstanceMap<B> extends ForwardingMap<java.lang.Class<? extends B>,B> implements ClassToInstanceMap<B>
A class-to-instance map backed by anImmutableMap. See alsoMutableClassToInstanceMap.- Since:
 - 2.0 (imported from Google Collections Library)
 
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImmutableClassToInstanceMap.Builder<B>A builder for creating immutable class-to-instance maps. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <B> ImmutableClassToInstanceMap.Builder<B>builder()Returns a new builder.static <B,S extends B>
ImmutableClassToInstanceMap<B>copyOf(java.util.Map<? extends java.lang.Class<? extends S>,? extends S> map)Returns an immutable map containing the same entries asmap.<T extends B>
TgetInstance(java.lang.Class<T> type)Returns the value the specified class is mapped to, ornullif no entry for this class is present.<T extends B>
TputInstance(java.lang.Class<T> type, T value)Deprecated.Unsupported operation.- 
Methods inherited from class com.google.common.collect.ForwardingMap
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values 
- 
Methods inherited from class com.google.common.collect.ForwardingObject
toString 
 - 
 
 - 
 
- 
- 
Method Detail
- 
builder
public static <B> ImmutableClassToInstanceMap.Builder<B> builder()
Returns a new builder. The generated builder is equivalent to the builder created by theImmutableClassToInstanceMap.Builderconstructor. 
- 
copyOf
public static <B,S extends B> ImmutableClassToInstanceMap<B> copyOf(java.util.Map<? extends java.lang.Class<? extends S>,? extends S> map)
Returns an immutable map containing the same entries asmap. Ifmapsomehow contains entries with duplicate keys (for example, if it is aSortedMapwhose comparator is not consistent with equals), the results of this method are undefined.Note: Despite what the method name suggests, if
mapis anImmutableClassToInstanceMap, no copy will actually be performed.- Throws:
 java.lang.NullPointerException- if any key or value inmapis nulljava.lang.ClassCastException- if any value is not an instance of the type specified by its key
 
- 
getInstance
@Nullable public <T extends B> T getInstance(java.lang.Class<T> type)
Description copied from interface:ClassToInstanceMapReturns the value the specified class is mapped to, ornullif no entry for this class is present. This will only return a value that was bound to this specific class, not a value that may have been bound to a subtype.- Specified by:
 getInstancein interfaceClassToInstanceMap<B>
 
- 
putInstance
@Deprecated public <T extends B> T putInstance(java.lang.Class<T> type, T value)
Deprecated.Unsupported operation.Guaranteed to throw an exception and leave the map unmodified.- Specified by:
 putInstancein interfaceClassToInstanceMap<B>- Returns:
 - the value previously associated with this class (possibly 
null), ornullif there was no previous entry. - Throws:
 java.lang.UnsupportedOperationException- always
 
 - 
 
 -