| Modifier and Type | Field and Description |
|---|---|
protected Map<String,String> |
attrs
附加属性
|
protected boolean |
enabled
是否启用当前结构,默认启用,禁用后会排除当前结构
|
protected String |
file
模板文件,当name不为空时,file是模板内容,当name为空时,file既是name,也是模板内容
|
protected List<Structure> |
files
子目录
|
protected String |
filter
绑定数据过滤器,使用 mvel 表达式,过滤条件不满足时不执行当前的操作
|
protected String |
id
项目id
|
protected String |
iter
绑定的数据源,使用 mvel 表达式
|
protected String |
iterName
迭代使用的名称
|
protected String |
itFilter
迭代数据过滤器,当指定
iter 时,对迭代的数据进行过滤 |
protected Mode |
mode
模式,默认覆盖 OVERRIDE,可选值参考
Mode |
protected String |
name
文件名,当file不为空时,文件内容为file;
当file为空的时候,name可以对应非模板文件,如果不存在对应的文件,文件内容为空。
|
protected Structure |
parent
父级
|
protected int |
times
模板被执行几次,默认1次
|
protected Type |
type
文件类型,可选
|
| Constructor and Description |
|---|
Structure() |
| Modifier and Type | Method and Description |
|---|---|
void |
addFiles(Structure... files)
设置子级的时候,同时设置父级信息
|
protected void |
autoStruct(Structure parent)
计算文件类型
|
void |
generator(Context context,
Structure parent,
Map<String,Object> params)
生成代码,主要处理数据(parent.parent..)
|
String |
getAttr(String attr)
获取属性值,当前不存在时默认向上逐级查找
|
String |
getAttr(String attr,
String defaultValue)
获取属性值,当前不存在时默认向上逐级查找
|
String |
getAttr(String attr,
String defaultValue,
boolean parents)
获取属性值,可以设置默认值和是否向上逐级查找
|
List<Structure> |
getFiles()
获取子文件
|
void |
initParams(Context context,
Map<String,Object> params)
初始化参数,需要在具体语境中初始化
|
void |
setFiles(List<Structure> files)
设置子级的时候,同时设置父级信息
|
String |
toString() |
protected String id
protected String name
protected String file
protected Type type
默认类型根据以下字段优先级判断
protected boolean enabled
protected int times
protected String iter
protected String iterName
protected String filter
protected transient Structure parent
public void initParams(Context context, Map<String,Object> params)
params - protected void autoStruct(Structure parent)
parent - public void generator(Context context, Structure parent, Map<String,Object> params)
context - parent - params - public String getAttr(String attr, String defaultValue)
attr - 属性名defaultValue - 默认值public String getAttr(String attr, String defaultValue, boolean parents)
attr - 属性名defaultValue - 默认值parents - 递归查找上级public void addFiles(Structure... files)
files - 子文件Copyright © 2023. All rights reserved.