aws / aws/aws-sdk-java-v2

Support DynamoDbConvertedBy annotation on type

Offen
#3,915 1 Kommentar 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
dynamodb-enhanced feature-request p3
Vorherrschende Sprache
Java
Sterne
2.6k
Forks
1k
Ø Merge
2 T. 9 Std.
Gemergte PRs (30 T.)
51

Beschreibung

### Describe the feature

Currently, `@DynamoDbConvertedBy` can be applied only to a property method. I would like to be able to apply it to a Java type, similar to Jackson `@JsonSerialize(using = Some.class)` and have it registered as a default.

### Use Case

I have a value type that I would like to be storable as a formatted string. Currently, for custom conversion I must either (create and) annotate every property getter that uses this value type with `@DynamoDbConvertedBy` or annotate every class that uses this type as a property with an `AttributeConverterProvider`. Instead, I would like to be able to say _on the converted type_ "use this converter globally".

### Proposed Solution

Allow `@DynamoDbConvertedBy` to target `TYPE`.

In `DefaultAttributeConverterProvider#findConverterInternal`, before checking `if (type.tableSchema().isPresent())`, check whether the `rawClass` has the `@DynamoDbConvertedBy` annotation. If it does, use that converter and skip the schema check.

### Other Information

_No response_

### Acknowledgements

- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### AWS Java SDK version used

2.19.25

### JDK version used

openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)

### Operating System and version

Gentoo Linux

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit DefaultAttributeConverterProvider#findConverterInternal und der Deklaration von @DynamoDbConvertedBy, wobei du dich darauf konzentrierst, wie der Roh-Typ und das Tabellenschema derzeit behandelt werden. Bestätige, dass die Annotation auf TYPE abzielen kann und dass ein Konverter auf Typebene vor der Schema-Behandlung als Standard ausgewählt wird; ergänze oder aktualisiere die Abdeckung für das angeforderte Verhalten, falls die umgebenden Tests einen geeigneten Ort erkennen lassen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
backend
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

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