@GwtIncompatible public final class ImmutableClassToInstanceMap<B> extends ForwardingMap<Class<? extends B>,B> implements ClassToInstanceMap<B>, Serializable
ClassToInstanceMap
whose contents will never change, with many
other important properties detailed at ImmutableCollection
.Modifier and Type | Class and Description |
---|---|
static class |
ImmutableClassToInstanceMap.Builder<B>
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<B> |
builder()
Returns a new builder.
|
static <B,S extends B> |
copyOf(Map<? extends Class<? extends S>,? extends S> map)
Returns an immutable map containing the same entries as
map . |
protected Map<Class<? extends B>,B> |
delegate()
Returns the backing delegate instance that methods are forwarded to.
|
<T extends B> |
getInstance(Class<T> type)
Returns the value the specified class is mapped to, or
null if no
entry for this class is present. |
static <B> ImmutableClassToInstanceMap<B> |
of()
Returns an empty
ImmutableClassToInstanceMap . |
static <B,T extends B> |
of(Class<T> type,
T value)
Returns an
ImmutableClassToInstanceMap containing a single entry. |
<T extends B> |
putInstance(Class<T> type,
T value)
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, values
toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
public static <B> ImmutableClassToInstanceMap<B> of()
ImmutableClassToInstanceMap
.public static <B,T extends B> ImmutableClassToInstanceMap<B> of(Class<T> type, T value)
ImmutableClassToInstanceMap
containing a single entry.public 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 nullClassCastException
- if any value is not an instance of the type
specified by its keyprotected Map<Class<? extends B>,B> delegate()
ForwardingObject
ForwardingSet.delegate()
. Concrete subclasses override this method to supply
the instance being decorated.delegate
in class ForwardingMap<Class<? extends B>,B>
@Nullable 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.getInstance
in interface ClassToInstanceMap<B>
@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
- alwaysCopyright © 2010-2017. All Rights Reserved.