Class BeanMap<T>
- Type Parameters:
T- the bean type | bean类型
Bean Map
Bean映射
Provides Map interface view of a bean's properties.
提供bean属性的Map接口视图。
Features | 主要功能:
- Map interface view of bean properties - bean属性的Map接口视图
- Read/write through Map operations - 通过Map操作读写
- Cross-bean property copying - 跨bean属性复制
Usage Examples | 使用示例:
BeanMap<User> map = BeanMap.from(user);
Object name = map.get("name");
map.put("name", "Alice");
Map<String, Object> plain = map.toMap();
Security | 安全性:
- Thread-safe: No (not synchronized) - 线程安全: 否(未同步)
- Null-safe: No (bean must be non-null) - 空值安全: 否(bean须非空)
- Since:
- JDK 25, opencode-base-reflect V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
ConstructorsConstructorDescriptionBeanMap(T bean, Map<String, PropertyDescriptor> descriptors) Creates a BeanMap 创建BeanMapBeanMap(T bean, Map<String, PropertyDescriptor> descriptors, boolean ignoreUnknownProperties) Creates a BeanMap with configuration 创建带配置的BeanMap -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(Object key) voidCopies properties from a Map 从Map复制属性<U> voidcopyTo(U target) Copies all properties to another bean 复制所有属性到另一个beanentrySet()static <T> BeanMap<T> from(T bean) Creates a BeanMap from a bean 从bean创建BeanMapgetBean()Gets the underlying bean 获取底层beangetPropertyDescriptor(String name) Gets property descriptor by name 按名称获取属性描述符Gets only readable properties as Map 仅获取可读属性为MapkeySet()intsize()toMap()Converts to a regular Map 转换为普通MapMethods inherited from class AbstractMap
clear, clone, containsValue, equals, hashCode, isEmpty, putAll, remove, toString, valuesMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
BeanMap
Creates a BeanMap 创建BeanMap- Parameters:
bean- the bean | beandescriptors- the property descriptors | 属性描述符
-
BeanMap
public BeanMap(T bean, Map<String, PropertyDescriptor> descriptors, boolean ignoreUnknownProperties) Creates a BeanMap with configuration 创建带配置的BeanMap- Parameters:
bean- the bean | beandescriptors- the property descriptors | 属性描述符ignoreUnknownProperties- whether to ignore unknown properties | 是否忽略未知属性
-
-
Method Details
-
from
Creates a BeanMap from a bean 从bean创建BeanMap- Type Parameters:
T- the bean type | bean类型- Parameters:
bean- the bean | bean- Returns:
- the BeanMap | BeanMap
-
getBean
-
get
-
put
-
containsKey
- Specified by:
containsKeyin interfaceMap<String,Object> - Overrides:
containsKeyin classAbstractMap<String,Object>
-
keySet
-
entrySet
-
size
-
copyTo
public <U> void copyTo(U target) Copies all properties to another bean 复制所有属性到另一个bean- Type Parameters:
U- the target type | 目标类型- Parameters:
target- the target bean | 目标bean
-
copyFrom
-
toMap
-
getReadableProperties
-
getPropertyDescriptor
Gets property descriptor by name 按名称获取属性描述符- Parameters:
name- the property name | 属性名- Returns:
- the descriptor or null | 描述符或null
-