forked from GitHub-Mirror/riotX-android
Get enum safe with realm entities
This commit is contained in:
parent
d9f448c9aa
commit
245fbe86d9
@ -18,20 +18,20 @@ package im.vector.matrix.android.internal.database.model
|
|||||||
|
|
||||||
import im.vector.matrix.android.api.session.room.model.Membership
|
import im.vector.matrix.android.api.session.room.model.Membership
|
||||||
import io.realm.RealmObject
|
import io.realm.RealmObject
|
||||||
import io.realm.annotations.Ignore
|
|
||||||
import io.realm.annotations.PrimaryKey
|
import io.realm.annotations.PrimaryKey
|
||||||
import kotlin.properties.Delegates
|
|
||||||
|
|
||||||
internal open class GroupEntity(@PrimaryKey var groupId: String = ""
|
internal open class GroupEntity(@PrimaryKey var groupId: String = ""
|
||||||
|
|
||||||
) : RealmObject() {
|
) : RealmObject() {
|
||||||
|
|
||||||
private var membershipStr: String = Membership.NONE.name
|
private var membershipStr: String = Membership.NONE.name
|
||||||
|
var membership: Membership
|
||||||
@delegate:Ignore
|
get() {
|
||||||
var membership: Membership by Delegates.observable(Membership.valueOf(membershipStr)) { _, _, newValue ->
|
return Membership.valueOf(membershipStr)
|
||||||
membershipStr = newValue.name
|
}
|
||||||
}
|
set(value) {
|
||||||
|
membershipStr = value.name
|
||||||
|
}
|
||||||
|
|
||||||
companion object
|
companion object
|
||||||
|
|
||||||
|
@ -19,9 +19,7 @@ package im.vector.matrix.android.internal.database.model
|
|||||||
import im.vector.matrix.android.api.session.room.model.Membership
|
import im.vector.matrix.android.api.session.room.model.Membership
|
||||||
import io.realm.RealmList
|
import io.realm.RealmList
|
||||||
import io.realm.RealmObject
|
import io.realm.RealmObject
|
||||||
import io.realm.annotations.Ignore
|
|
||||||
import io.realm.annotations.PrimaryKey
|
import io.realm.annotations.PrimaryKey
|
||||||
import kotlin.properties.Delegates
|
|
||||||
|
|
||||||
internal open class RoomEntity(@PrimaryKey var roomId: String = "",
|
internal open class RoomEntity(@PrimaryKey var roomId: String = "",
|
||||||
var chunks: RealmList<ChunkEntity> = RealmList(),
|
var chunks: RealmList<ChunkEntity> = RealmList(),
|
||||||
@ -31,11 +29,13 @@ internal open class RoomEntity(@PrimaryKey var roomId: String = "",
|
|||||||
) : RealmObject() {
|
) : RealmObject() {
|
||||||
|
|
||||||
private var membershipStr: String = Membership.NONE.name
|
private var membershipStr: String = Membership.NONE.name
|
||||||
|
var membership: Membership
|
||||||
@delegate:Ignore
|
get() {
|
||||||
var membership: Membership by Delegates.observable(Membership.valueOf(membershipStr)) { _, _, newValue ->
|
return Membership.valueOf(membershipStr)
|
||||||
membershipStr = newValue.name
|
}
|
||||||
}
|
set(value) {
|
||||||
|
membershipStr = value.name
|
||||||
|
}
|
||||||
|
|
||||||
companion object
|
companion object
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,7 @@ import im.vector.matrix.android.api.session.room.model.Membership
|
|||||||
import im.vector.matrix.android.api.session.room.model.VersioningState
|
import im.vector.matrix.android.api.session.room.model.VersioningState
|
||||||
import io.realm.RealmList
|
import io.realm.RealmList
|
||||||
import io.realm.RealmObject
|
import io.realm.RealmObject
|
||||||
import io.realm.annotations.Ignore
|
|
||||||
import io.realm.annotations.PrimaryKey
|
import io.realm.annotations.PrimaryKey
|
||||||
import kotlin.properties.Delegates
|
|
||||||
|
|
||||||
internal open class RoomSummaryEntity(@PrimaryKey var roomId: String = "",
|
internal open class RoomSummaryEntity(@PrimaryKey var roomId: String = "",
|
||||||
var displayName: String? = "",
|
var displayName: String? = "",
|
||||||
@ -41,18 +39,22 @@ internal open class RoomSummaryEntity(@PrimaryKey var roomId: String = "",
|
|||||||
) : RealmObject() {
|
) : RealmObject() {
|
||||||
|
|
||||||
private var membershipStr: String = Membership.NONE.name
|
private var membershipStr: String = Membership.NONE.name
|
||||||
|
var membership: Membership
|
||||||
|
get() {
|
||||||
|
return Membership.valueOf(membershipStr)
|
||||||
|
}
|
||||||
|
set(value) {
|
||||||
|
membershipStr = value.name
|
||||||
|
}
|
||||||
|
|
||||||
private var versioningStateStr: String = VersioningState.NONE.name
|
private var versioningStateStr: String = VersioningState.NONE.name
|
||||||
|
var versioningState: VersioningState
|
||||||
|
get() {
|
||||||
@delegate:Ignore
|
return VersioningState.valueOf(versioningStateStr)
|
||||||
var membership: Membership by Delegates.observable(Membership.valueOf(membershipStr)) { _, _, newValue ->
|
}
|
||||||
membershipStr = newValue.name
|
set(value) {
|
||||||
}
|
versioningStateStr = value.name
|
||||||
|
}
|
||||||
@delegate:Ignore
|
|
||||||
var versioningState: VersioningState by Delegates.observable(VersioningState.valueOf(versioningStateStr)) { _, _, newValue ->
|
|
||||||
versioningStateStr = newValue.name
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object
|
companion object
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user