Kotlin and @Transient

Viewed 12324

hava a class:

open class MessageDTO : RealmObject, Serializable {

    @PrimaryKey
    @SerializedName("message_id")
    var messageId: String? = null

    @SerializedName("chat")
    var chat: String? = null

    @SerializedName("chat_type")
    var chatType: String? = null

    @SerializedName("content")
    var content: ContentDTO? = null

    @SerializedName("created")
    var created: Date? = null

    @SerializedName("from")
    var from: String? = null

    @SerializedName("important")
    var important: Boolean? = null

    @SerializedName("is_first")
    var isFirst: Boolean? = null

    @SerializedName("is_group")
    var isGroup: Boolean? = null

    @SerializedName("is_last")
    var isLast: Boolean? = null

    @SerializedName("linked_messages")
    var linkedMessages: RealmList<MessageDTO>? = null

    @SerializedName("links")
    var links: RealmList<ModelLinks>? = null

    @SerializedName("read")
    var read: Boolean? = null

    @SerializedName("to")
    var to: String? = null

    @Ignore
    var displayName: String? = null

    @Ignore
    var authorPhoto: ModelIcons? = null

    @Transient
    var deliveredToServer: Boolean = false

and need to use @Transient with variable deliveredToServer but have compile error:

e: error: Class "MessageDTO" contains illegal transient field "deliveredToServer". e:

e: java.lang.IllegalStateException: failed to analyze: org.jetbrains.kotlin.kapt3.diagnostic.KaptError: Error while annotation processing

what could be the problem?

1 Answers

Transient fields were not supported in 3.1.3 and had to be explicitly ignored with @Ignore.

See the change log.

3.2.0 (2017-05-16)

Transient fields are now allowed in model classes, but are implicitly treated as having the @Ignore annotation (#4279).

Related