public class BeanPath extends Object
表达式:
persion persion.name persons[3] person.friends[5].name ['person']['friends'][5]['name']
| Modifier and Type | Field and Description |
|---|---|
protected List<String> |
patternParts |
| Modifier and Type | Method and Description |
|---|---|
static BeanPath |
create(String expression)
解析Bean路径表达式为Bean模式
Bean表达式,用于获取多层嵌套Bean中的字段值或Bean对象
根据给定的表达式,查找Bean中对应的属性值对象。 表达式分为两种:
.表达式,可以获取Bean对象中的属性(字段)值或者Map中key对应的值
[]表达式,可以获取集合等对象中对应index的值
|
Object |
get(Object bean)
获取Bean中对应表达式的值
|
void |
set(Object bean,
Object value)
设置表达式指定位置(或filed对应)的值
若表达式指向一个List则设置其坐标对应位置的值,若指向Map则put对应key的值,Bean则设置字段的值
注意:
|
public BeanPath(String expression)
expression - 表达式public static BeanPath create(String expression)
表达式栗子:
persion persion.name persons[3] person.friends[5].name ['person']['friends'][5]['name']
expression - 表达式BeanPathpublic Object get(Object bean)
bean - Bean对象或Map或List等Copyright © 2019. All rights reserved.