storio: GetResolver fails to generate properly with Kotlin nullable -> java boxed types
Hi 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
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (5 by maintainers)
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.