gpt4 book ai didi

android - Kotlin 和@Transient

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:26:19 26 4
gpt4 key购买 nike

上课:

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

并且需要使用带有变量deliveredToServer@Transient但有编译错误:

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

可能是什么问题?

最佳答案

transient 字段在 3.1.3 中不受支持,必须使用 @Ignore 明确忽略。

查看更改日志。

3.2.0 (2017-05-16)

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

关于android - Kotlin 和@Transient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47091180/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com