我想使用红石映射器将 Json 解码为对象。但是颤振不支持镜像,因此我无法以正常方式初始化映射器bootstrapMapper();
因此我查了一下,我必须使用staticBootstrapMapper(...)
/**
* initialize the mapper system.
*
* This function provides a mapper implementation that
* uses data generated by the redstone_mapper's transformer,
* instead of relying on the mirrors API.
*
*/
void staticBootstrapMapper(Map<Type, TypeInfo> types) {
_staticTypeInfo = types;
configure(_getOrCreateMapper, _createValidator);
}
我不知道我应该在地图中添加什么Map<Type, TypeInfo> types
。假设我想使用ObjectData将 json 数据转换为这个对象。
但是我该如何使用这种初始化方法呢?不幸的是,我没有找到如何使用这个静态引导管理器的示例。
class ObjectData {
@Field()
@NotEmpty()
DataType dateType; // might be a User object
@Field()
@NotEmpty()
String id;
@Field()
@NotEmpty()
List<String> versions;
}