Object
TypeToken to an instance of that type. In addition to
implementing Map, the additional type-safe operations putInstance and getInstance are available.
Generally, implementations don't support put and putAll because there is no
way to check an object at runtime to be an instance of a TypeToken. Instead, caller
should use the type safe putInstance.
Also, if caller suppresses unchecked warnings and passes in an Iterable<String> for
type Iterable<Integer>, the map won't be able to detect and throw type error.
Like any other Map<Class, Object>, this map may contain entries for primitive types,
and a primitive type and its corresponding wrapper type may map to different values.
| Modifier and Type | Method and Description |
|---|---|
| public <T extends @NonNull B> T | getInstance(Class<T> type)
Returns the value the specified class is mapped to, or |
| public <T extends @NonNull B> T | getInstance(TypeToken<T> type)
Returns the value the specified type is mapped to, or |
| public <T extends B> T | Returns: the value previously associated with this class (possiblynull), or null if there was no previous entry.Maps the specified class to the specified value. |
| public <T extends B> T | Returns: the value previously associated with this type (possiblynull), or null
if there was no previous entry.Maps the specified type to the specified value. |
| getInstance | back to summary |
|---|---|
| public <T extends @NonNull B> T getInstance(Class<T> type) Returns the value the specified class is mapped to, or
| |
| getInstance | back to summary |
|---|---|
| public <T extends @NonNull B> T getInstance(TypeToken<T> type) Returns the value the specified type is mapped to, or
| |
| putInstance | back to summary |
|---|---|
| public <T extends B> T putInstance(Class<@NonNull T> type, T value) Maps the specified class to the specified value. Does not associate this value with any of the class's supertypes.
| |
| putInstance | back to summary |
|---|---|
| public <T extends B> T putInstance(TypeToken<@NonNull T> type, T value) Maps the specified type to the specified value. Does not associate this value with any of the type's supertypes.
| |