Skip to content

Allow specifying custom type converters per table or globally too #899

Description

@ridcully99

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions