googleapis / googleapis/google-cloud-java

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

Đang mở
#13,137 1 bình luận 6 reaction 0 người được giao Xem trên GitHub
api: firestore type: feature request
Ngôn ngữ chính
Java
Star
2.1k
Fork
1.2k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
154

Mô tả

**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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.