jfinal的model和record如何相互转化?

jfinal的model和record如何相互转化?

https://www.cnblogs.com/YuyuanNo1/p/9962022.html

https://my.oschina.net/u/2450343/blog/859638

一、model转record:

Model类:

1、

/**
* Convert model to record.
*/
public Record toRecord() {
return new Record().setColumns(getAttrs());
}

Record 类


2、
/**
* Set columns value with map.
* @param columns the columns map
*/
public Record setColumns(Map<String, Object> columns) {
this.getColumns().putAll(columns);
return this;
}

3、
/**
* Set columns value with Model object.
* @param model the Model object
*/
public Record setColumns(Model<?> model) {
getColumns().putAll(model.getAttrs());
return this;
}


二、record转model:

model类:

public M put(Record record) {
attrs.putAll(record.getColumns());
return (M)this;
}
上一篇:力扣242题(有效的字母异位词)


下一篇:设计模式 桥接模式 其在JDK中的应用