googleapis / googleapis/google-cloud-java

[java-firestore] Feature Request: Support configuration of mapper to allow use of Kotlin serialization/deserialization semantics

Abierto
#13,137 1 comentario 6 reacciones 0 asignados Ver en GitHub
api: firestore type: feature request
Lenguaje dominante
Java
Estrellas
2.1k
Forks
1.2k
Merge medio
1 d 23 h
PR fusionados (30 d)
154

Descripción

**Is your feature request related to a problem? Please describe.**

Currently the implementation mostly follows "Java" way of serialization. Kotlin allows to be more precise, consider following snippet:

```kotlin
data class MyEntity(
val name: String
)
```

When using Jackson's object mapper with KotlinModule:

```kotlin
val objectMapper = ObjectMapper()
.registerModule(KotlinModule())
```

We are able to (de)serialize such entities even though they don't have any default constructor.

Unfortunately Firestore's object mapper doesn't use Jackson and the Kotlin's advantages cannot be used. When using a data class without default constructor, it leads to:

```
Could not deserialize object. Class MyEntity does not define a no-argument constructor. If you are using ProGuard, make sure these constructors are not stripped
at com.google.cloud.firestore.CustomClassMapper.deserializeError(CustomClassMapper.java:614) ~[google-cloud-firestore-2.1.0.jar:2.1.0]
at com.google.cloud.firestore.CustomClassMapper.access$200(CustomClassMapper.java:53) ~[google-cloud-firestore-2.1.0.jar:2.1.0]
at com.google.cloud.firestore.CustomClassMapper$BeanMapper.deserialize(CustomClassMapper.java:800) ~[google-cloud-firestore-2.1.0.jar:2.1.0]
at com.google.cloud.firestore.CustomClassMapper$BeanMapper.deserialize(CustomClassMapper.java:792) ~[google-cloud-firestore-2.1.0.jar:2.1.0]
at com.google.cloud.firestore.CustomClassMapper.convertBean(CustomClassMapper.java:593) ~[google-cloud-firestore-2.1.0.jar:2.1.0]
```

**Describe the solution you'd like**
Profit from the Kotlin's features and allow for a no argument constructor.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.