Destructuring accessors for SecureCellData in Kotlin #638
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the final item of API updates planned in RFC 3.9.
Kotlin supports tuples and destructuring assignment which results in a much nicer APIs with multiple return values. Implement special accessor methods for SecureCellData to enable that:
This is implemented by a couple of special methods. They are available to users (i.e., IDEs will show them up in Java autocomplete) but these methods are not intended for general use. The methods also have appropriate
@NotNull
annotations to make Kotlin experience better.Initially, RFC 3.9 also suggested some accessor renaming for Java:
getProtectedData()
⟹getEncryptedData()
getAdditionalData()
⟹getToken()
However, after giving it a second though, I believe that we don’t need to do this. Renaming is hard, it causes developer pain. While it is justified with new Secure Cell API that has its own improvements, here we’d be renaming for the sake of renaming. While the names are not ideal, they are not that ambiguous either. Furthermore, Android users are likely to use Kotlin in the first place so they will not have to deal with these names anymore.
Checklist
Example projects and code samples are up-to-date(no Kotlin examples)