Class ImmutableClassToInstanceMap<B>
java.lang.Object
com.google.common.collect.ForwardingObject
com.google.common.collect.ForwardingMap<Class<? extends @NonNull B>, B>
com.google.common.collect.ImmutableClassToInstanceMap<B>
- All Implemented Interfaces:
- ClassToInstanceMap<B>,- Serializable,- Map<Class<? extends B>, B>
@Immutable(containerOf="B")
@GwtIncompatible
public final class ImmutableClassToInstanceMap<B>
extends ForwardingMap<Class<? extends @NonNull B>, B>
implements ClassToInstanceMap<B>, Serializable
A 
ClassToInstanceMap whose contents will never change, with many other important
 properties detailed at ImmutableCollection.- Since:
- 2.0
- Author:
- Kevin Bourrillion
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic final classA builder for creating immutable class-to-instance maps.Nested classes/interfaces inherited from class com.google.common.collect.ForwardingMapForwardingMap.StandardEntrySet, ForwardingMap.StandardKeySet, ForwardingMap.StandardValues
- 
Method SummaryModifier and TypeMethodDescriptionstatic <B> ImmutableClassToInstanceMap.Builder<B> builder()Returns a new builder.static <B, S extends B>
 ImmutableClassToInstanceMap<B> Returns an immutable map containing the same entries asmap.delegate()Returns the backing delegate instance that methods are forwarded to.getInstance(Class<T> type) Returns the value the specified class is mapped to, ornullif no entry for this class is present.static <B> ImmutableClassToInstanceMap<B> of()Returns an emptyImmutableClassToInstanceMap.static <B, T extends B>
 ImmutableClassToInstanceMap<B> Returns anImmutableClassToInstanceMapcontaining a single entry.putInstance(Class<T> type, T value) Deprecated.Unsupported operation.Methods inherited from class com.google.common.collect.ForwardingMapclear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, standardClear, standardContainsKey, standardContainsValue, standardEquals, standardHashCode, standardIsEmpty, standardPutAll, standardRemove, standardToString, valuesMethods inherited from class com.google.common.collect.ForwardingObjecttoStringMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Mapclear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
- 
Method Details- 
ofReturns an emptyImmutableClassToInstanceMap.Performance note: the instance returned is a singleton. - Since:
- 19.0
 
- 
ofReturns anImmutableClassToInstanceMapcontaining a single entry.- Since:
- 19.0
 
- 
builderReturns a new builder. The generated builder is equivalent to the builder created by theImmutableClassToInstanceMap.Builderconstructor.
- 
copyOfpublic static <B, S extends B> ImmutableClassToInstanceMap<B> copyOf(Map<? extends 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:
- NullPointerException- if any key or value in- mapis null
- ClassCastException- if any value is not an instance of the type specified by its key
 
- 
delegateDescription copied from class:ForwardingObjectReturns the backing delegate instance that methods are forwarded to. Abstract subclasses generally override this method with an abstract method that has a more specific return type, such asForwardingSet.delegate(). Concrete subclasses override this method to supply the instance being decorated.
- 
getInstanceDescription 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 interface- ClassToInstanceMap<B>
 
- 
putInstance@CanIgnoreReturnValue @Deprecated public <T extends B> @Nullable T putInstance(Class<T> type, T value) Deprecated.Unsupported operation.Guaranteed to throw an exception and leave the map unmodified.- Specified by:
- putInstancein interface- ClassToInstanceMap<B>
- Returns:
- the value previously associated with this class (possibly null), ornullif there was no previous entry.
- Throws:
- UnsupportedOperationException- always
 
 
-