81 lines
3.0 KiB
Plaintext
81 lines
3.0 KiB
Plaintext
|
{{~if __namespace_with_top_module != ''~}}
|
||
|
package {{__namespace_with_top_module}};
|
||
|
{{~end~}}
|
||
|
|
||
|
import luban.*;
|
||
|
|
||
|
|
||
|
{{~if __this.comment != '' ~}}
|
||
|
/**
|
||
|
* {{escape_comment __this.comment}}
|
||
|
*/
|
||
|
{{~end~}}
|
||
|
public final class {{__name}} {
|
||
|
{{~if __this.is_map_table
|
||
|
key_type = __this.key_ttype
|
||
|
~}}
|
||
|
private final java.util.HashMap<{{declaring_box_type_name key_type}}, {{declaring_box_type_name __value_type}}> _dataMap;
|
||
|
private final java.util.ArrayList<{{declaring_box_type_name __value_type}}> _dataList;
|
||
|
|
||
|
public {{__name}}(ByteBuf _buf) {
|
||
|
_dataMap = new java.util.HashMap<{{declaring_box_type_name key_type}}, {{declaring_box_type_name __value_type}}>();
|
||
|
_dataList = new java.util.ArrayList<{{declaring_box_type_name __value_type}}>();
|
||
|
|
||
|
for(int n = _buf.readSize() ; n > 0 ; --n) {
|
||
|
{{declaring_box_type_name __value_type}} _v;
|
||
|
{{deserialize '_buf' '_v' __value_type}}
|
||
|
_dataList.add(_v);
|
||
|
_dataMap.put(_v.{{format_field_name __code_style __this.index_field.name}}, _v);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public java.util.HashMap<{{declaring_box_type_name key_type}}, {{declaring_box_type_name __value_type}}> getDataMap() { return _dataMap; }
|
||
|
public java.util.ArrayList<{{declaring_box_type_name __value_type}}> getDataList() { return _dataList; }
|
||
|
|
||
|
{{~if __value_type.is_dynamic~}}
|
||
|
@SuppressWarnings("unchecked")
|
||
|
public <T extends {{declaring_box_type_name __value_type}}> T getAs({{declaring_type_name key_type}} key) { return (T)_dataMap.get(key); }
|
||
|
{{~end~}}
|
||
|
public {{declaring_box_type_name __value_type}} get({{declaring_type_name key_type}} key) { return _dataMap.get(key); }
|
||
|
|
||
|
{{~else if __this.is_list_table ~}}
|
||
|
private final java.util.ArrayList<{{declaring_box_type_name __value_type}}> _dataList;
|
||
|
|
||
|
public {{__name}}(ByteBuf _buf) {
|
||
|
_dataList = new java.util.ArrayList<{{declaring_box_type_name __value_type}}>();
|
||
|
|
||
|
for(int n = _buf.readSize() ; n > 0 ; --n) {
|
||
|
{{declaring_box_type_name __value_type}} _v;
|
||
|
{{deserialize '_buf' '_v' __value_type}}
|
||
|
_dataList.add(_v);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public java.util.ArrayList<{{declaring_box_type_name __value_type}}> getDataList() { return _dataList; }
|
||
|
|
||
|
public {{declaring_box_type_name __value_type}} get(int index) { return _dataList.get(index); }
|
||
|
|
||
|
|
||
|
{{~else~}}
|
||
|
private final {{declaring_type_name __value_type}} _data;
|
||
|
|
||
|
public final {{declaring_type_name __value_type}} data() { return _data; }
|
||
|
|
||
|
public {{__name}}(ByteBuf _buf) {
|
||
|
int n = _buf.readSize();
|
||
|
if (n != 1) throw new SerializationException("table mode=one, but size != 1");
|
||
|
{{deserialize '_buf' '_data' __value_type}}
|
||
|
}
|
||
|
|
||
|
|
||
|
{{~ for field in __value_type.def_bean.hierarchy_export_fields ~}}
|
||
|
{{~if field.comment != '' ~}}
|
||
|
/**
|
||
|
* {{escape_comment field.comment}}
|
||
|
*/
|
||
|
{{~end~}}
|
||
|
public {{declaring_type_name field.ctype}} {{getter_name field.name}}() { return _data.{{format_field_name __code_style field.name}}; }
|
||
|
{{~end~}}
|
||
|
|
||
|
{{~end~}}
|
||
|
}
|