All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.ContainerTrait.vm Maven / Gradle / Ivy

There is a newer version: 3.5.12
Show newest version
#* @vtlvariable name="formatedFactoryName" type="java.lang.String" *#
#* @vtlvariable name="packElem" type="java.lang.String" *#
#* @vtlvariable name="ctx" type="org.kevoree.modeling.kotlin.generator.GenerationContext" *#
#* @vtlvariable name="FQNHelper" type="org.kevoree.modeling.kotlin.generator.ProcessorHelper" *#


package ${packElem}

trait ${formatedFactoryName}Impl {

    internal open var internal_eContainer : org.kevoree.modeling.api.${formatedFactoryName}?
    internal open var internal_unsetCmd : RemoveFromContainerCommand?

    fun eContainer() : org.kevoree.modeling.api.${formatedFactoryName}? { return internal_eContainer }

    internal open var internal_containmentRefName : String?

    internal open var internal_readOnlyElem : Boolean

    internal open var internal_recursive_readOnlyElem : Boolean

    open fun setRecursiveReadOnly()
    open fun reflexiveMutator(mutatorType : Int,refName : String, value : Any?)

    fun setInternalReadOnly(){
        internal_readOnlyElem = true
    }

    fun getRefInParent() : String? {
        return internal_containmentRefName
    }

    fun isReadOnly() : Boolean {
        return internal_readOnlyElem
    }

    fun isRecursiveReadOnly() : Boolean {
        return internal_recursive_readOnlyElem
    }

    fun setEContainer( container : org.kevoree.modeling.api.${formatedFactoryName}?, unsetCmd : RemoveFromContainerCommand?, refNameInParent : String? ) {

        if(internal_readOnlyElem){return}

        val tempUnsetCmd = internal_unsetCmd
        internal_unsetCmd = null
        if(tempUnsetCmd != null){
            tempUnsetCmd.run()
        }
        internal_eContainer = container
        internal_unsetCmd = unsetCmd

        internal_containmentRefName = refNameInParent

    }

#if($ctx.genSelector)

#else
    fun selectByQuery(query : String) : List {
        throw Exception("Not activated, please add selector option in KMF generation plugin")
    }

#end


#if(${ctx.jS})
fun getClonelazy(subResult : java.util.HashMap, _factories : ${FQNHelper.fqn($ctx, ${ctx.getBasePackageForUtilitiesGeneration()})}.factory.MainFactory, mutableOnly: Boolean)
fun resolve(addrs : java.util.HashMap,readOnly:Boolean, mutableOnly: Boolean) : Any
#else
fun getClonelazy(subResult : java.util.IdentityHashMap, _factories : ${FQNHelper.fqn($ctx, ${ctx.getBasePackageForUtilitiesGeneration()})}.factory.MainFactory, mutableOnly: Boolean)
fun resolve(addrs : java.util.IdentityHashMap,readOnly:Boolean, mutableOnly: Boolean) : Any
#end

#if(${ctx.isGenTrace()})
    #set($tracePack=${FQNHelper.fqn($ctx, $ctx.getBasePackageForUtilitiesGeneration())})
    fun generateDiffTraces(similarObj : org.kevoree.modeling.api.KMFContainer?, inter : Boolean) : List
#end

#if($ctx.generateEvents())
    internal var internal_modelElementListeners : MutableList?

    protected fun fireModelEvent(evt : org.kevoree.modeling.api.events.ModelEvent) {
        if(internal_modelElementListeners != null) {
            for(lst in internal_modelElementListeners!!) {
                lst.elementChanged(evt)
            }
        }
        fireModelEventOnTree(evt)
    }

        fun addModelElementListener(lst : org.kevoree.modeling.api.events.ModelElementListener){
            if(internal_modelElementListeners == null) {
                internal_modelElementListeners = java.util.ArrayList()
            }
            internal_modelElementListeners!!.add(lst)
        }

        fun removeModelElementListener(lst : org.kevoree.modeling.api.events.ModelElementListener){
            if(internal_modelElementListeners != null) {
                internal_modelElementListeners!!.remove(lst)
                if(internal_modelElementListeners!!.isEmpty()) {
                    internal_modelElementListeners = null
                }
            }
        }

        fun removeAllModelElementListeners() {
            if(internal_modelElementListeners != null) {
                internal_modelElementListeners!!.clear()
                internal_modelElementListeners = null
            }
        }

        internal var internal_modelTreeListeners : MutableList?

        private fun fireModelEventOnTree(evt: org.kevoree.modeling.api.events.ModelEvent) {
            if(internal_modelTreeListeners != null) {
                for(lst in internal_modelTreeListeners!!) {
                    lst.elementChanged(evt)
                }
            }
            if(eContainer() != null) {
                (eContainer() as KMFContainerImpl).fireModelEventOnTree(evt)
            }
        }

        fun addModelTreeListener(lst : org.kevoree.modeling.api.events.ModelElementListener){
            if(internal_modelTreeListeners == null) {
                internal_modelTreeListeners = java.util.ArrayList()
            }
            internal_modelTreeListeners!!.add(lst)
        }

        fun removeModelTreeListener(lst : org.kevoree.modeling.api.events.ModelElementListener){
            if(internal_modelTreeListeners != null) {
                internal_modelTreeListeners!!.remove(lst)
                if(internal_modelTreeListeners!!.isEmpty()) {
                    internal_modelTreeListeners = null
                }
            }
        }

        fun removeAllModelTreeListeners() {
            if(internal_modelTreeListeners != null) {
                internal_modelTreeListeners!!.clear()
                internal_modelElementListeners = null
            }
        }

#else
    fun addModelElementListener(lst : org.kevoree.modeling.api.events.ModelElementListener){
        throw Exception("Not activated, please add events option in KMF generation plugin")
    }
    fun removeModelElementListener(lst : org.kevoree.modeling.api.events.ModelElementListener ){
        throw Exception("Not activated, please add events option in KMF generation plugin")
    }
    fun removeAllModelElementListeners(){
        throw Exception("Not activated, please add events option in KMF generation plugin")
    }
    fun addModelTreeListener(lst : org.kevoree.modeling.api.events.ModelElementListener){
        throw Exception("Not activated, please add events option in KMF generation plugin")
    }
    fun removeModelTreeListener(lst : org.kevoree.modeling.api.events.ModelElementListener){
        throw Exception("Not activated, please add events option in KMF generation plugin")
    }
    fun removeAllModelTreeListeners(){
        throw Exception("Not activated, please add events option in KMF generation plugin")
    }
#end
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy