Interface ClassToInstanceMap<B>
- Type Parameters:
B- base type | 基础类型
- All Known Implementing Classes:
MutableClassToInstanceMap
ClassToInstanceMap - Class to Instance Map Interface
ClassToInstanceMap - 类实例映射接口
A type-safe map from Class objects to instances of that class.
从 Class 对象到该类实例的类型安全映射。
Features | 主要功能:
- Type-safe retrieval - 类型安全检索
- Type-safe storage - 类型安全存储
- Extends Map interface - 扩展 Map 接口
Usage Examples | 使用示例:
ClassToInstanceMap<Object> map = MutableClassToInstanceMap.create();
map.putInstance(String.class, "hello");
map.putInstance(Integer.class, 42);
String str = map.getInstance(String.class); // Type-safe
Integer num = map.getInstance(Integer.class);
Security | 安全性:
- Thread-safe: Implementation-dependent - 取决于实现
- Null-safe: Partial (getInstance returns null for missing) - 部分(getInstance对缺失返回null)
- Since:
- JDK 25, opencode-base-collections V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescription<T extends B>
TgetInstance(Class<T> type) Get the instance for the given type in a type-safe manner.<T extends B>
TputInstance(Class<T> type, T value) Put the instance for the given type in a type-safe manner.Methods inherited from interface Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Method Details
-
getInstance
-
putInstance
-