GetResolver fails to generate properly with Kotlin nullable -> java boxed types
See original GitHub issueHi everyone! This is my data class for a StorIO table with 5 columns using Kotlin
@StorIOSQLiteType(table = AttachmentTable.TABLE)
data class Attachment @StorIOSQLiteCreator constructor(
@get:StorIOSQLiteColumn(name = AttachmentTable.COLUMN_MESSAGE_ID) val messageId: String,
@get:StorIOSQLiteColumn(name = AttachmentTable.COLUMN_URL) val url: String,
@get:StorIOSQLiteColumn(name = AttachmentTable.COLUMN_THUMBNAIL_URL) val thumbnailUrl: String,
@get:StorIOSQLiteColumn(name = AttachmentTable.COLUMN_ID, key = true) var id: Long? = null,
@get:StorIOSQLiteColumn(name = AttachmentTable.COLUMN_BYTES) var bytes: Long? = null)
And this is the generated AttachmentStorIOSQLiteGetResolver
@Override
@NonNull
public Attachment mapFromCursor(@NonNull Cursor cursor) {
String messageId = cursor.getString(cursor.getColumnIndex("messageId"));
String url = cursor.getString(cursor.getColumnIndex("url"));
String thumbnailUrl = cursor.getString(cursor.getColumnIndex("thumbnailUrl"));
Longid= null;
if(!cursor.isNull(cursor.getColumnIndex("_id"))) {
id = cursor.getLong(cursor.getColumnIndex("_id"));
}
Longbytes= null;
if(!cursor.isNull(cursor.getColumnIndex("bytes"))) {
bytes = cursor.getLong(cursor.getColumnIndex("bytes"));
}
Attachment object = new Attachment(messageId, url, thumbnailUrl, id, bytes);
return object;
}
As you can see, everything appears correct except there is a space missing between the type (Long) and the variable name (id, bytes) causing a compilation error. Should be an easy fix?
More examples of types (Kotlin -> Java Generated)
-
Okay ** Long -> long ** String -> String
-
Broken ** Long? -> Long ** Int? -> Integer
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (5 by maintainers)
Top Results From Across the Web
Nullability in Java and Kotlin
This guide covers support for nullable types in Kotlin, how Kotlin treats nullable annotations from Java, and more.
Read more >Why can a java nullable returned value be assigned to a ...
The Kotlin compiler has no way of determining if it can return a nullable value or not since for Java only nullable types...
Read more >Chapter 6. The Kotlin type system - Kotlin in Action
This chapter covers. Nullable types and syntax for dealing with null s; Primitive types and their correspondence to the Java types; Kotlin collections...
Read more >Use of Boolean? in Kotlin if Statement - Baeldung
Instead, we have “boxed” primitive types like Int and Boolean. Kotlin's nullable Boolean type Boolean? is pretty similar to Java's Boolean type.
Read more >Kotlin is not primitive! (Primitives in Kotlin and Java) - Medium
Recently I had a little conversation about primitives. You known, that strange type of data you always put on stack, you cannot assign...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The problem was just in missing space for boxed types in Kotlin/AutoValue case. Now it’s fixed and fix will be available in the next version.
Hey thanks for fixing this @geralt-encore I’ll give it a go as soon as I can!!