我的目标是将大型平面文件映射到bean。文件内部的示例如下。
平面文件,作为键值对读取到HashMap
:
addressname=the name
addressstreet=the street
addresszip=12345
addresstown=the town
addressmail=the@mail.com
personage=14
personname=
//many more fields...
目标bean:
public class Address {
private String name, street, zip, town, mail;
}
问题:哪个映射框架(dozer,orika)提供HashMap
密钥的部分映射?
在任何框架中都可能使用以下伪代码:
-> if any key starts with "address"
-> split (eg to address.name, address.street)
-> take 1st part as field name of an object, and 2nd part as nested property.
或者:
定义某种类型的后缀,它始终表示嵌套对象的属性:`address{suffix}` -> map to class `address.{fieldname}`
。
其中一个映射框架能够实现吗?