in dnq-transient-store/src/main/kotlin/com/jetbrains/teamsys/dnq/association/PrimitiveAssociationSemantics.kt [106:135]
fun set(e: Entity, propertyName: String, propertyValue: Comparable<*>?, clazz: Class<*>?): Comparable<*>? {
val txnEntity = e.reattachTransient()
if (propertyValue == null) {
txnEntity.deleteProperty(propertyName)
} else {
// strict casting
when (clazz) {
Int::class.javaPrimitiveType,
Int::class.javaObjectType ->
txnEntity.setProperty(propertyName, (propertyValue as Number).toInt())
Long::class.javaPrimitiveType,
Long::class.javaObjectType ->
txnEntity.setProperty(propertyName, (propertyValue as Number).toLong())
Double::class.javaPrimitiveType,
Double::class.javaObjectType ->
txnEntity.setProperty(propertyName, (propertyValue as Number).toDouble())
Float::class.javaPrimitiveType,
Float::class.javaObjectType ->
txnEntity.setProperty(propertyName, (propertyValue as Number).toFloat())
Short::class.javaPrimitiveType,
Short::class.javaObjectType ->
txnEntity.setProperty(propertyName, (propertyValue as Number).toShort())
Byte::class.javaPrimitiveType,
Byte::class.javaObjectType ->
txnEntity.setProperty(propertyName, (propertyValue as Number).toByte())
else -> txnEntity.setProperty(propertyName, propertyValue) // boolean, string and date
}
}
return propertyValue
}