AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Kotlin assign if not null4/30/2023 ![]() I wrote a quick JUnit test case with the gist of the function code all in one. cloud and local have different sizes and some from local is missing in cloud and some from cloud is missing in local - cloudList only adds those missing that local has.delete coming later.cloud list has more items local has less but all repeated in cloud - cloudList no changes(delete coming later).local list has more items than cloud - cloudList adds only those items to its list.cloud list empty - cloudList adds all devices from local.Not-Null Assertion Each type in Kotlin has one nullable form and another non-nullable form. In this quick tutorial, we’re going to introduce the not-null assertion ( ) operator and see how and when we should use it. local list and cloud list same - cloudList no changes In Kotlin, nullability is a type system feature that can help us to avoid NullPointerException s.local list empty - cloudList has no changes.both lists empty - cloudList has no changes. ![]() Val differences: MutableList = mutableListOf() ![]() ![]() So here is what I have there has to be a cleaner way, I've tried using filter, filterNot, but this seems to work for all the test cases: val tempList = convertLocalObjectToCloud(Id, localObjectsList) We have to send the whole list not just the new one, again client decision on that one. If it is not then we take that object and add it to the list of cloud objects and send an update. ![]() Due to timing issues and just bad RXJava programming that we can't touch right now, we want to check if its been stored in the cloud. So at some point we add a new object it always comes from local. Problem is due to Legacy code the device in the cloud has to be mapped to the type that is stored locally on the DB. I have two lists one from a local DB and another from JSON cloud query. ![]()
0 Comments
Read More
Leave a Reply. |