
commonMain.maryk.core.values.ObjectValues.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core-jvm Show documentation
Show all versions of core-jvm Show documentation
Maryk is a Kotlin Multiplatform library which helps you to store, query and send data in a structured way over multiple platforms. The data store stores any value with a version, so it is possible to request only the changed data or live listen for updates.
The newest version!
package maryk.core.values
import maryk.core.models.IsObjectDataModel
import maryk.core.models.IsStorableDataModel
import maryk.core.models.IsTypedObjectDataModel
import maryk.core.query.RequestContext
typealias SimpleObjectValues = ObjectValues>
/**
* Contains a [map] with all values related to a DataObject of [dataModel]
*/
data class ObjectValues> internal constructor(
override val dataModel: DM,
override val values: IsValueItems,
override val context: RequestContext? = null
) : AbstractValues() {
/**
* Converts values to a strong typed DataObject.
* Will throw exception if values is missing values for a complete DataObject
*/
@Suppress("UNCHECKED_CAST")
fun toDataObject() = (this.dataModel as IsTypedObjectDataModel).invoke(this)
// ignore context
override fun equals(other: Any?) = when {
this === other -> true
other !is ObjectValues<*, *> -> false
dataModel != other.dataModel -> false
values != other.values -> false
else -> true
}
// ignore context
override fun hashCode(): Int {
var result = dataModel.hashCode()
result = 31 * result + values.hashCode()
return result
}
override fun toString(): String {
val modelName = (dataModel as? IsStorableDataModel<*>)?.Meta?.name ?: dataModel
return "ObjectValues<$modelName>$values"
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy