@GwtIncompatible public final class ImmutableClassToInstanceMap<B> extends ForwardingMap<java.lang.Class<? extends B>,B> implements ClassToInstanceMap<B>, java.io.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(java.util.Map<? extends java.lang.Class<? extends S>,? extends S> map)
Returns an immutable map containing the same entries as
map . |
protected java.util.Map<java.lang.Class<? extends B>,B> |
delegate()
Returns the backing delegate instance that methods are forwarded to.
|
<T extends B> |
getInstance(java.lang.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(java.lang.Class<T> type,
T value)
Returns an
ImmutableClassToInstanceMap containing a single entry. |
<T extends B> |
putInstance(java.lang.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
public static <B> ImmutableClassToInstanceMap<B> of()
ImmutableClassToInstanceMap
.public static <B,T extends B> ImmutableClassToInstanceMap<B> of(java.lang.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(java.util.Map<? extends java.lang.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.
java.lang.NullPointerException
- if any key or value in map
is nulljava.lang.ClassCastException
- if any value is not an instance of the type specified by its keyprotected java.util.Map<java.lang.Class<? extends B>,B> delegate()
ForwardingObject
ForwardingSet.delegate()
. Concrete subclasses override this method to supply the
instance being decorated.delegate
in class ForwardingMap<java.lang.Class<? extends B>,B>
@NullableDecl public <T extends B> T getInstance(java.lang.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>
@CanIgnoreReturnValue @Deprecated public <T extends B> T putInstance(java.lang.Class<T> type, T value)
putInstance
in interface ClassToInstanceMap<B>
null
), or null
if there was no previous entry.java.lang.UnsupportedOperationException
- alwaysCopyright © 2010–2019 JBoss by Red Hat. All rights reserved.