public final class ImmutableClassToInstanceMap<B> extends ForwardingMap<Class <? extends B> ,B> implements ClassToInstanceMap <B>, Serializable
ImmutableMap. See also
MutableClassToInstanceMap.
| Modifier and Type | Class and Description |
|---|---|
static class |
ImmutableClassToInstanceMap
A builder for creating immutable class-to-instance maps.
|
ForwardingMap.StandardEntrySet , ForwardingMap.StandardKeySet , ForwardingMap.StandardValues | Modifier and Type | Method and Description |
|---|---|
static <B> ImmutableClassToInstanceMap |
builder()
Returns a new builder.
|
static <B |
copyOf(Map
Returns an immutable map containing the same entries as
map.
|
protected Map |
delegate()
Returns the backing delegate instance that methods are forwarded to.
|
<T extends B> T |
getInstance(Class
Returns the value the specified class is mapped to, or
null if no entry for this class is present.
|
<T extends B> T |
putInstance(Class
Deprecated.
Unsupported operation.
|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, standardClear, standardContainsKey, standardContainsValue, standardEquals, standardHashCode, standardIsEmpty, standardPutAll, standardRemove, standardToString, valuestoStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitclear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuespublic static <B> ImmutableClassToInstanceMap.Builder <B> builder()
ImmutableClassToInstanceMap.Builder constructor.
public static <B,S extends B> ImmutableClassToInstanceMap <B> copyOf(Map <? extends Class <? extends S> ,? extends S> map)
map. If
map somehow contains entries with duplicate keys (for example, if it is a
SortedMap whose comparator is not
consistent with equals), the results of this method are undefined.
Note: Despite what the method name suggests, if map is an ImmutableClassToInstanceMap, no copy will actually be performed.
NullPointerException - if any key or value in
map is null
ClassCastException - if any value is not an instance of the type specified by its key
protected Map<Class <? extends B> ,B> delegate()
ForwardingObject
ForwardingSet.delegate() . Concrete subclasses override this method to supply the instance being decorated.
public <T extends B> T getInstance(Class<T> type)
ClassToInstanceMap
null if 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.
@Deprecated public <T extends B> T putInstance(Class<T> type, T value)
putInstance in interface
ClassToInstanceMap<B>
null), or
null if there was no previous entry.
UnsupportedOperationException - always