Package com.google.common.collect
Class ImmutableClassToInstanceMap<B>
-
- com.google.common.collect.ForwardingObject
-
- <? extends B>,B>
-
- com.google.common.collect.ImmutableClassToInstanceMap<B>
-
- All Implemented Interfaces:
,
<<? extends B>,B>
(="B") @GwtIncompatible public final class ImmutableClassToInstanceMap<B> extends <? extends B>,B> implements
AClassToInstanceMap
whose contents will never change, with many other important properties detailed atImmutableCollection
.- Since:
- 2.0
- Author:
- Kevin Bourrillion
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description 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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <B> ImmutableClassToInstanceMap.Builder<B>
builder()
Returns a new builder.static <B,S extends B>
ImmutableClassToInstanceMap<B><? extends <? extends S>,? extends S> map)
Returns an immutable map containing the same entries asmap
.protected <<? extends B>,B>
delegate()
Returns the backing delegate instance that methods are forwarded to.<T extends T
<T> type)
Returns the value the specified class is mapped to, ornull
if no entry for this class is present.static <B> ImmutableClassToInstanceMap<B>
of()
Returns an emptyImmutableClassToInstanceMap
.static <B,T extends B>
ImmutableClassToInstanceMap<B><T> type, T value)
Returns anImmutableClassToInstanceMap
containing a single entry.<T extends B>
T<T> type, T value)
Deprecated.Unsupported operation.-
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
-
-
-
-
Method Detail
-
of
public static <B> ImmutableClassToInstanceMap<B> of()
Returns an emptyImmutableClassToInstanceMap
.- Type Parameters:
B
- theMap
's key type- Returns:
- an empty
Map
- Since:
- 19.0
-
of
public static <B,T extends B> <T> type, T value)
Returns anImmutableClassToInstanceMap
containing a single entry.- Type Parameters:
B
- theMap
's key typeT
- theMap
's value type- Parameters:
type
- the mapping's keyvalue
- the mapping's value- Returns:
- a
Map
containing the specified mapping - Since:
- 19.0
-
builder
public static <B> ImmutableClassToInstanceMap.Builder<B> builder()
Returns a new builder. The generated builder is equivalent to the builder created by theImmutableClassToInstanceMap.Builder
constructor.
-
copyOf
public static <B,S extends B> <? extends <? extends S>,? extends S> map)
Returns an immutable map containing the same entries asmap
. 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.- Type Parameters:
B
- theMap
's key typeS
- theMap
's value type- Parameters:
map
- aMap
from which entries are drawn, must be non-null- Returns:
- a
Map
containing the entries of the givenMap
- Throws:
- if any key or value in
map
is null- if any value is not an instance of the type specified by its key
-
delegate
protected <<? 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 asForwardingSet.delegate()
. Concrete subclasses override this method to supply the instance being decorated.
-
getInstance
public <T extends T <T> type)
Description copied from interface:ClassToInstanceMap
Returns the value the specified class is mapped to, ornull
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 <T> type, T value)
Deprecated.Unsupported operation.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:
- always
-
-