Class BeanPath
java.lang.Object
cloud.opencode.base.reflect.bean.BeanPath
Bean Path Navigator
Bean路径导航器
Navigates nested bean properties using path expressions. Supports dot notation (e.g., "user.address.city").
使用路径表达式导航嵌套bean属性。 支持点号表示法(如 "user.address.city")。
Features | 主要功能:
- Dot notation path navigation - 点号表示法路径导航
- Indexed property access (list, array, map) - 索引属性访问(列表、数组、映射)
- Nested property read/write - 嵌套属性读写
- Path existence checking - 路径存在检查
Usage Examples | 使用示例:
// Get nested property
String city = BeanPath.get(user, "address.city", String.class);
// Set nested property
BeanPath.set(user, "address.city", "Beijing");
// Indexed access
Object item = BeanPath.get(order, "items[0].name");
Security | 安全性:
- Thread-safe: Yes (stateless utility class) - 线程安全: 是(无状态工具类)
- Null-safe: Partially (returns null for null bean or intermediate null) - 空值安全: 部分(null bean或中间null返回null)
- Since:
- JDK 25, opencode-base-reflect V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidCopies a property from one path to another 从一个路径复制属性到另一个路径static ObjectGets a nested property value 获取嵌套属性值static <T> TGets a nested property value with type 获取嵌套属性值(带类型)static <T> TgetOrDefault(Object bean, String path, T defaultValue) Gets a nested property value or default 获取嵌套属性值或默认值getPathValues(Object bean, String path) Gets all values along a path 获取路径上的所有值static booleanChecks if a path exists and is readable 检查路径是否存在且可读static voidSets a nested property value 设置嵌套属性值
-
Method Details
-
get
-
get
-
getOrDefault
Gets a nested property value or default 获取嵌套属性值或默认值- Type Parameters:
T- the value type | 值类型- Parameters:
bean- the root bean | 根beanpath- the property path | 属性路径defaultValue- the default value | 默认值- Returns:
- the value or default | 值或默认值
-
set
-
hasPath
-
getPathValues
-
copy
Copies a property from one path to another 从一个路径复制属性到另一个路径- Parameters:
source- the source bean | 源beansourcePath- the source path | 源路径target- the target bean | 目标beantargetPath- the target path | 目标路径
-