objectbox / objectbox/objectbox-java

Allow specifying custom type converters per table or globally too

Đang mở
#899 1 bình luận 5 reaction 1 người được giao Xem trên GitHub

@greenrobot-team đang làm issue này rồi.

Từ ngày 24/8/2020.

enhancement
Ngôn ngữ chính
Java
Star
4.6k
Fork
311
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.