com.fastchar.object.FastObjectExecute Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fastchar Show documentation
Show all versions of fastchar Show documentation
FastChar is Web+ORM Framework in Java.
package com.fastchar.object;
import com.fastchar.utils.FastNumberUtils;
import com.fastchar.utils.FastStringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 表达式读取对象的值
*
* @author 沈建(Janesen)
* @date 2021/8/20 10:02
*/
public class FastObjectExecute {
private static final Pattern ATTR_PATTERN = Pattern.compile("\\$\\{(.*)}");
private static final Pattern EXTRACT_PATTERN = Pattern.compile("(.*)\\[(\\d+)]");
private transient final Object value;
public FastObjectExecute(Object value) {
this.value = value;
}
public Object execute(String expression) {
return executeProperty(expression).getValue();
}
public FastObjectProperty executeProperty(String expression) {
if (FastStringUtils.isEmpty(expression)) {
return new FastObjectProperty(value, expression);
}
Matcher matcher = ATTR_PATTERN.matcher(expression);
if (matcher.find()) {
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy