aws / aws/aws-sdk-java-v2

Support DynamoDbConvertedBy annotation on type

Aperta
#3,915 1 commento 3 reazioni 0 assegnatari Vedi su GitHub
dynamodb-enhanced feature-request p3
Lingua principale
Java
Stelle
2.6k
Fork
1k
Merge medio
2g 9h
PR unite (30g)
51

Descrizione

### 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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con DefaultAttributeConverterProvider#findConverterInternal e la dichiarazione di @DynamoDbConvertedBy, concentrandoti su come vengono attualmente gestiti il tipo grezzo e lo schema della tabella. Conferma che l’annotazione può avere come target TYPE e che un convertitore a livello di tipo viene selezionato come predefinito prima della gestione dello schema; aggiungi o aggiorna la copertura per il comportamento richiesto se i test circostanti individuano una posizione adatta.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
backend
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.