2017-11-03 5 views
0

HAVAクラス:Kotlinと@Transient

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

問題何ができますか?

+1

'@field:[Transient]'を試してみることができますか? – Joshua

+0

これはどのバージョンのレルムですか? – EpicPandaForce

+0

@エピックパンダフォース '3.1.3' –

答えて

2

トランジェントフィールドは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).

+0

ありがとう、それは仕事 –