|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.common.collect.ForwardingObject com.google.common.collect.ForwardingMap<Class<? extends B>,B> com.google.common.collect.ImmutableClassToInstanceMap<B>
public final class ImmutableClassToInstanceMap<B>
A class-to-instance map backed by an ImmutableMap
. See also MutableClassToInstanceMap
.
Nested Class Summary | |
---|---|
static class |
ImmutableClassToInstanceMap.Builder<B>
A builder for creating immutable class-to-instance maps. |
Nested classes/interfaces inherited from class com.google.common.collect.ForwardingMap |
---|
ForwardingMap.StandardEntrySet, ForwardingMap.StandardKeySet, ForwardingMap.StandardValues |
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Method Summary | ||
---|---|---|
static
|
builder()
Returns a new builder. |
|
static
|
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. |
|
|
getInstance(Class<T> type)
Returns the value the specified class is mapped to, or null if no
entry for this class is present. |
|
|
putInstance(Class<T> type,
T value)
Guaranteed to throw an exception and leave the map unmodified. |
Methods inherited from class com.google.common.collect.ForwardingMap |
---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, standardClear, standardContainsKey, standardContainsValue, standardEquals, standardHashCode, standardIsEmpty, standardPutAll, standardRemove, standardToString, values |
Methods inherited from class com.google.common.collect.ForwardingObject |
---|
toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
Method Detail |
---|
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 null
ClassCastException
- 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>
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>
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |