objectbox / objectbox/objectbox-java

Allow specifying custom type converters per table or globally too

Offen
#899 1 Kommentar 5 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@greenrobot-team arbeitet bereits daran.

Seit 24.8.2020.

enhancement
Vorherrschende Sprache
Java
Sterne
4.6k
Forks
311
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.