javadoc.com.google.common.collect.ImmutableClassToInstanceMap.html Maven / Gradle / Ivy
The newest version!
ImmutableClassToInstanceMap (Guava: Google Core Libraries for Java 11.0.1 API)
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
com.google.common.collect
Class ImmutableClassToInstanceMap<B>
java.lang.Object
com.google.common.collect.ForwardingObject
com.google.common.collect.ForwardingMap<Class<? extends B>,B>
com.google.common.collect.ImmutableClassToInstanceMap<B>
- All Implemented Interfaces:
- ClassToInstanceMap<B>, Map<Class<? extends B>,B>
public final class ImmutableClassToInstanceMap<B>
- extends ForwardingMap<Class<? extends B>,B>
- implements ClassToInstanceMap<B>
A class-to-instance map backed by an ImmutableMap
. See also MutableClassToInstanceMap
.
- Since:
- 2.0 (imported from Google Collections Library)
- Author:
- Kevin Bourrillion
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 |
---|
builder
public static <B> ImmutableClassToInstanceMap.Builder<B> builder()
- Returns a new builder. The generated builder is equivalent to the builder
created by the
ImmutableClassToInstanceMap.Builder
constructor.
copyOf
public static <B,S extends B> ImmutableClassToInstanceMap<B> copyOf(Map<? extends Class<? extends S>,? extends S> map)
- Returns an immutable map containing the same entries as
map
. Ifmap
somehow contains entries with duplicate keys (for example, if it is aSortedMap
whose comparator is not consistent with equals), the results of this method are undefined.Note: Despite what the method name suggests, if
map
is anImmutableClassToInstanceMap
, no copy will actually be performed.- Throws:
NullPointerException
- if any key or value inmap
is nullClassCastException
- if any value is not an instance of the type specified by its key
delegate
protected Map<Class<? extends B>,B> delegate()
- Description copied from class:
ForwardingObject
- Returns 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 as
ForwardingSet.delegate()
. Concrete subclasses override this method to supply the instance being decorated.- Specified by:
delegate
in classForwardingMap<Class<? extends B>,B>
getInstance
public <T extends B> T getInstance(Class<T> type)
- Description copied from interface:
ClassToInstanceMap
- Returns the value the specified class is mapped to, or
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.- Specified by:
getInstance
in interfaceClassToInstanceMap<B>
putInstance
public <T extends B> T putInstance(Class<T> type, T value)
- Guaranteed to throw an exception and leave the map unmodified.
- Specified by:
putInstance
in interfaceClassToInstanceMap<B>
- Returns:
- the value previously associated with this class (possibly
null
), ornull
if there was no previous entry. - Throws:
UnsupportedOperationException
- always
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2010-2012. All Rights Reserved.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy