fun setOneToOne()

in dnq-transient-store/src/main/kotlin/com/jetbrains/teamsys/dnq/association/AggregationAssociationSemantics.kt [40:50]


    fun setOneToOne(parent: Entity?, parentToChildLinkName: String, childToParentLinkName: String, child: Entity?) {
        val txnParent = parent?.reattachTransient()
        val txnChild = child?.reattachTransient()

        when {
            txnParent != null && txnChild != null -> txnParent.setChild(parentToChildLinkName, childToParentLinkName, txnChild)
            txnParent != null && txnChild == null -> txnParent.removeChild(parentToChildLinkName, childToParentLinkName)
            txnParent == null && txnChild != null -> txnChild.removeFromParent(parentToChildLinkName, childToParentLinkName)
            txnParent == null && txnChild == null -> throw IllegalArgumentException("Both entities can't be null.")
        }
    }