objectbox / objectbox/objectbox-java
Allow specifying custom type converters per table or globally too
@greenrobot-team 已经在做这个了。
开始于 2020年8月24日。
- 主要语言
- Java
- 星标
- 4.6k
- 派生
- 311
- PR 合并指标
- 30 天内没有已合并 PR
描述
Currently, to convert a custom type, we have to annotate each field of that type individually with @Convert.
This is very inconvenientt, because if you have a custom type, e.g. joda.time.DateTime you'll always want to convert it, so it would be much cleaner and less error-prone if we could define custom type converters per table or for the whole database too, like Room does it with TypeConverters.
Describe the solution you'd like
For a per-entity definition of converters, one could extend the @Entity annotation something like this:
@Entity(converters={@Convert(...), @Convert(...),...}
public class User ...
For defining converters globally, the ObjectBox builder could be extended.
Describe alternatives you've considered
Currently, the only alternative is to add @Convert to each and every field.
Additional context
As said above, you can have a look at Room's @TypeConverter annotation that can be applied to METHOD, PARAMETER, TYPE and FIELD.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
评估
这个 Issue 还没有评估数据。