[英]Kotlin and @Transient
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: 需要用
@Transient
可变deliveredToServer
但有编译错误:
e: error: Class "MessageDTO" contains illegal transient field "deliveredToServer".
e:错误:类“MessageDTO”包含非法的瞬态字段“deliveredToServer”。 e:
E:
e: java.lang.IllegalStateException: failed to analyze: org.jetbrains.kotlin.kapt3.diagnostic.KaptError: Error while annotation processing
e:java.lang.IllegalStateException:无法分析:org.jetbrains.kotlin.kapt3.diagnostic.KaptError:注释处理时出错
what could be the problem? 可能是什么问题呢?
Transient fields were not supported in 3.1.3 and had to be explicitly ignored with @Ignore
. 3.1.3不支持瞬态字段,必须使用
@Ignore
明确忽略。
See the change log. 请参阅更改日志。
3.2.0 (2017-05-16)
3.2.0(2017-05-16)
Transient fields are now allowed in model classes, but are implicitly treated as having the @Ignore annotation (#4279).
现在,模型类中允许使用瞬态字段,但隐式地将其视为具有@Ignore注释(#4279)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.