Top Description Inners Fields Constructors Methods
com.google.common.reflect

public final Class MutableTypeToInstanceMap<B extends @Nullable Object>

extends ForwardingMap<TypeToken<? extends @NonNull B extends @Nullable Object>, B extends @Nullable Object>
implements TypeToInstanceMap<B extends @Nullable Object>
Class Inheritance
All Implemented Interfaces
com.google.common.reflect.TypeToInstanceMap, java.util.Map
Annotations
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull

A mutable type-to-instance map. See also ImmutableTypeToInstanceMap.
Author
Ben Yu
Since
13.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final Map<TypeToken<? extends @NonNull B>, B>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected Map<TypeToken<? extends @NonNull B>, B>
delegate()

Implements abstract com.google.common.collect.ForwardingMap.delegate.

Returns the backing delegate instance that methods are forwarded to.
public Set<Map.Entry<TypeToken<? extends @NonNull B>, B>>
entrySet()

Overrides com.google.common.collect.ForwardingMap.entrySet.

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.
public <T extends @NonNull B> T
getInstance(Class<T> type)

Implements com.google.common.reflect.TypeToInstanceMap.getInstance.

Returns the value the specified class is mapped to, or null if no entry for this class is present.
public <T extends @NonNull B> T
getInstance(TypeToken<T> type)

Implements com.google.common.reflect.TypeToInstanceMap.getInstance.

Returns the value the specified type is mapped to, or null if no entry for this type is present.
public B
put(TypeToken<? extends @NonNull B>
key with which the specified value is to be associated
key
,
B
value to be associated with the specified key
value
)

Overrides com.google.common.collect.ForwardingMap.put.

Implements java.util.Map.put.

Deprecated unsupported operation
Not supported.
public void
putAll(Map<? extends TypeToken<? extends @NonNull B>, ? extends B>
mappings to be stored in this map
map
)

Overrides com.google.common.collect.ForwardingMap.putAll.

Implements java.util.Map.putAll.

Deprecated unsupported operation
Not supported.
public <T extends B> T
putInstance(Class<@NonNull T> type, T value)

Implements com.google.common.reflect.TypeToInstanceMap.putInstance.

Maps the specified class to the specified value.
public <T extends B> T
putInstance(TypeToken<@NonNull T> type, T value)

Implements com.google.common.reflect.TypeToInstanceMap.putInstance.

Maps the specified type to the specified value.
private <T extends @NonNull B> T
private <T extends B> T
trustedPut(TypeToken<@NonNull T> type, T value)

Inherited from com.google.common.collect.ForwardingMap:
clearcontainsKeycontainsValueequalsgethashCodeisEmptykeySetremovesizestandardClearstandardContainsKeystandardContainsValuestandardEqualsstandardHashCodestandardIsEmptystandardPutAllstandardRemovestandardToStringvalues

Field Detail

backingMapback to summary
private final Map<TypeToken<? extends @NonNull B>, B> backingMap

Constructor Detail

MutableTypeToInstanceMapback to summary
public MutableTypeToInstanceMap()

Method Detail

delegateback to summary
protected Map<TypeToken<? extends @NonNull B>, B> delegate()

Implements abstract com.google.common.collect.ForwardingMap.delegate.

Doc from com.google.common.collect.ForwardingObject.delegate.

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.

Annotations
@Override
entrySetback to summary
public Set<Map.Entry<TypeToken<? extends @NonNull B>, B>> entrySet()

Overrides com.google.common.collect.ForwardingMap.entrySet.

Implements java.util.Map.entrySet.

Doc from java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Returns:Set<Map.Entry<TypeToken<? extends @NonNull B>, B>>

a set view of the mappings contained in this map

Annotations
@Override
getInstanceback to summary
public <T extends @NonNull B> T getInstance(Class<T> type)

Implements com.google.common.reflect.TypeToInstanceMap.getInstance.

Doc from com.google.common.reflect.TypeToInstanceMap.getInstance.

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.

getInstance(Foo.class) is equivalent to getInstance(TypeToken.of(Foo.class)).

Annotations
@Override
@CheckForNull
getInstanceback to summary
public <T extends @NonNull B> T getInstance(TypeToken<T> type)

Implements com.google.common.reflect.TypeToInstanceMap.getInstance.

Doc from com.google.common.reflect.TypeToInstanceMap.getInstance.

Returns the value the specified type is mapped to, or null if no entry for this type is present. This will only return a value that was bound to this specific type, not a value that may have been bound to a subtype.

Annotations
@Override
@CheckForNull
putback to summary
public B put(TypeToken<? extends @NonNull B> key, B value)

Overrides com.google.common.collect.ForwardingMap.put.

Implements java.util.Map.put.

Deprecated

unsupported operation

Not supported. Use putInstance instead.

Parameters
key:TypeToken<? extends @NonNull B>

Doc from java.util.Map.put.

key with which the specified value is to be associated

value:B

Doc from java.util.Map.put.

value to be associated with the specified key

Returns:B

Doc from java.util.Map.put.

the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)

Annotations
@CanIgnoreReturnValue
@Deprecated
@Override
@DoNotCall:Always throws UnsupportedOperationException
@CheckForNull
Exceptions
UnsupportedOperationException:
always
putAllback to summary
public void putAll(Map<? extends TypeToken<? extends @NonNull B>, ? extends B> map)

Overrides com.google.common.collect.ForwardingMap.putAll.

Implements java.util.Map.putAll.

Deprecated

unsupported operation

Not supported. Use putInstance instead.

Parameters
map:Map<? extends TypeToken<? extends @NonNull B>, ? extends B>

Doc from java.util.Map.putAll.

mappings to be stored in this map

Annotations
@Deprecated
@Override
@DoNotCall:Always throws UnsupportedOperationException
Exceptions
UnsupportedOperationException:
always
putInstanceback to summary
public <T extends B> T putInstance(Class<@NonNull T> type, T value)

Implements com.google.common.reflect.TypeToInstanceMap.putInstance.

Doc from com.google.common.reflect.TypeToInstanceMap.putInstance.

Maps the specified class to the specified value. Does not associate this value with any of the class's supertypes.

putInstance(Foo.class, foo) is equivalent to putInstance(TypeToken.of(Foo.class), foo).

Returns:T

the value previously associated with this class (possibly null), or null if there was no previous entry.

Annotations
@Override
@CanIgnoreReturnValue
@CheckForNull
putInstanceback to summary
public <T extends B> T putInstance(TypeToken<@NonNull T> type, T value)

Implements com.google.common.reflect.TypeToInstanceMap.putInstance.

Doc from com.google.common.reflect.TypeToInstanceMap.putInstance.

Maps the specified type to the specified value. Does not associate this value with any of the type's supertypes.

Returns:T

the value previously associated with this type (possibly null), or null if there was no previous entry.

Annotations
@Override
@CanIgnoreReturnValue
@CheckForNull
trustedGetback to summary
private <T extends @NonNull B> T trustedGet(TypeToken<T> type)
Annotations
@SuppressWarnings:unchecked
@CheckForNull
trustedPutback to summary
private <T extends B> T trustedPut(TypeToken<@NonNull T> type, T value)
Annotations
@SuppressWarnings:unchecked
@CheckForNull
com.google.common.reflect back to summary

private final Class MutableTypeToInstanceMap.UnmodifiableEntry<K, V extends @Nullable Object>

extends ForwardingMapEntry<K, V extends @Nullable Object>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Map.Entry<K, V>

Constructor Summary

AccessConstructor and Description
private
UnmodifiableEntry(Map.Entry<K, V> delegate)

Method Summary

Modifier and TypeMethod and Description
protected Map.Entry<K, V>
delegate()

Implements abstract com.google.common.collect.ForwardingMapEntry.delegate.

Returns the backing delegate instance that methods are forwarded to.
public V
setValue(V
new value to be stored in this entry
value
)

Overrides com.google.common.collect.ForwardingMapEntry.setValue.

Implements java.util.Map.Entry.setValue.

Replaces the value corresponding to this entry with the specified value (optional operation).
pack-priv static <K, V extends @Nullable Object> Set<Map.Entry<K, V>>
transformEntries(Set<Map.Entry<K, V>> entries)

private static <K, V extends @Nullable Object> Iterator<Map.Entry<K, V>>
Inherited from com.google.common.collect.ForwardingMapEntry:
equalsgetKeygetValuehashCodestandardEqualsstandardHashCodestandardToString

Field Detail

delegateback to summary
private final Map.Entry<K, V> delegate

Constructor Detail

UnmodifiableEntryback to summary
private UnmodifiableEntry(Map.Entry<K, V> delegate)

Method Detail

delegateback to summary
protected Map.Entry<K, V> delegate()

Implements abstract com.google.common.collect.ForwardingMapEntry.delegate.

Doc from com.google.common.collect.ForwardingObject.delegate.

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.

Annotations
@Override
setValueback to summary
public V setValue(V value)

Overrides com.google.common.collect.ForwardingMapEntry.setValue.

Implements java.util.Map.Entry.setValue.

Doc from java.util.Map.Entry.setValue.

Replaces the value corresponding to this entry with the specified value (optional operation). (Writes through to the map.) The behavior of this call is undefined if the mapping has already been removed from the map (by the iterator's remove operation).

Parameters
value:V

new value to be stored in this entry

Returns:V

old value corresponding to the entry

Annotations
@Override
@ParametricNullness
transformEntriesback to summary
pack-priv static <K, V extends @Nullable Object> Set<Map.Entry<K, V>> transformEntries(Set<Map.Entry<K, V>> entries)
transformEntriesback to summary
private static <K, V extends @Nullable Object> Iterator<Map.Entry<K, V>> transformEntries(Iterator<Map.Entry<K, V>> entries)