Closed AlBlanc closed 5 years ago
Hi @AlBlanc,
We intentionally make DictionaryInterface
nonpublic. It forces the implementation class to have the declared methods.
Thanks,
Hideki
Ok. Then would have been great to have Document
inherit from Dictionary
(but looks more complicated) or even a getter for Document.dictionary
private field.
I am just looking for a way to avoid duplicate code because i treat them equally during the serialization process of my ORM (eg: nested documents -> nested classes). But I'll copy/paste it if there is no other way.
Nevermind, I went deeper into the project and I may found something. I think i'll work with the method public Dictionary set(Map<String, Object> dictionary)
and copy the static method CBLData.convert(Object valut)
@hideki I have the same problem with @AlBlanc Due to the DictionaryInterface is not public, I have to write unmarshalling code for Result and Document twice. Hard to manage.
Is there any workaround or trick to do not make the duplicated code? Or is there any special reason for DictionaryInterface is non-public? Forcing classes to implement methods cannot be a reason for not-public
Hi @mswokk,
Actually I have just finished to rewrite completely my "Document mapper" (I can't say ORM for the moment yet) in kotlin, and I have done it without needed these interfaces.
If you want to have a look -> https://github.com/Sportner/CBLMapper
You can register custom types, it handles enums, arrays (use Arralist and HashMap as default list/map). It still under construction but works pretty well. :)
Actually, Sorry @mswokk I replied too quickly, I am facing exactly the same issue as you.
I still don't see the point to make DictionnaryInterface
not public... It would help us to build products on top of it...
FYI you can have a look at how I did to have as less duplicate code as possible -> https://github.com/Sportner/CBLMapper/blob/master/cblmapper/src/main/java/io/sportner/cblmapper/CBLMapper.kt#L91
CBL iOS (Objective-C) and .NET have DictionaryInterface public. We probably should do the in CBL Android.
@pasin Please consider ArrayInterface too.
Absolutely.
@AlBlanc Thank you for answer. If you are hurrying up, please check my workaround.
I created Kotlin extension function for each classes which implements DictionaryInterface, ArrayInterface. Although my codes are duplicated, once you import it, you can use it everywhere in your own document.
Opened https://issues.couchbase.com/browse/CBL-32 to track this. Please follow it there.
Fixed in couchbase-lite-java:26e89439318531d05
Hello CB team,
I am writing an ORM for couchbase lite 2.0 and i am getting stuck. I need
DictionaryInterface
to be public to make a common flow usable for Document and Dictionnary (for nested object)Thank you!