我有一个Entity
为我的数据库创建的数据类。
这是我的数据类:
@Entity
@Parcelize
data class Tapligh(
@PrimaryKey(autoGenerate = true)
var id: Long,
@SerializedName("title") var title: String?,
@SerializedName("type") var type: Int?,
@SerializedName("os") var os: Int?,
@SerializedName("logo") var logo: String?,
@SerializedName("template") var template: String?,
@SerializedName("action") var action: String?,
@SerializedName("date") var date: String?,
@Embedded
@SerializedName("videos") var videos: Videos?,
) : Parcelable {
fun getTaplighType(): Int {
return when (this.type) {
0 -> TaplighType.IMAGE.type
1 -> TaplighType.VIDEO.type
else -> TaplighType.NATIVE.type
}
}
}
@Parcelize
data class Videos(
@SerializedName("land") var land: String?,
@SerializedName("port") var port: String?
) : Parcelable
现在通过将以下字段添加到我的Tapligh
数据类中,我会收到一个错误:
@Ignore
@SerializedName("images") var images: List<String>?
我收到此错误:
error: Entities and Pojos must have a usable public constructor. You can have an empty constructor or a constructor whose parameters match the fields (by name and type).
public final class Tapligh implements android.os.Parcelable {
^