I have a list of fields I would like every entity to have, so I've created a Base Entity.
open class Syncable(
@ColumnInfo(name = "id")
var oid: String? = null,
@ColumnInfo(name = "created")
var created: Long = System.currentTimeMillis(),
@ColumnInfo(name = "updated")
var updated: Long = System.currentTimeMillis())
Then I have a number of entities inheriting from this one, like:
@Entity(tableName = ProfileContract.TABLE_NAME, indices = [Index(value = ["id"], unique = true)])
data class Profile(ColumnInfo(name = "first_name")
var firstName: String,
@ColumnInfo(name = "last_name")
var lastName: String,
@ColumnInfo(name = "email")
var email: String? = null,
@PrimaryKey(autoGenerate = true) @ColumnInfo(name = "row_id")
var id: Long? = null) : Syncable()
Now when I want to construct one of these entities. How do I do it?
Currently I do:
val newProfile = Profile(
"Bob",
"Shoruncle",
"bobshoruncle@test.com)
newProfile.id = "bob1"
newProfile.created = 1233L
newProfile.updated = 1233L
Is there a way to do it as:
val newProfile = Profile("Bob", "Shoruncle", "bobshoruncle@test.com","bob1",1233L,1233L)