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

odeling.org.kevoree.modeling.kotlin.generator.1.4.2.source-code.CompositeIterator.vm Maven / Gradle / Ivy

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

package ${packElem}.util;

#set($mutableOrNot="Mutable")

public class CompositeIterator(val subLists : List) : ${mutableOrNot}Iterator<${ctx.getKevoreeContainer().get()}> {


    private var i = 0;
    private var its : Iterator<${ctx.getKevoreeContainer().get()}>? = null;
    private var currentObj : ${ctx.getKevoreeContainer().get()}?  = null;

    override fun hasNext() : Boolean {
        /* case 1..1 dep */
        if(currentObj != null){
            return true;
        }
        if (its != null && its!!.hasNext()) {
            return true;
        }
        if (i >= subLists.size) {
            return false;
        } else {
            var currentIndice = subLists.get(i);
            i = i +1;
            if(currentIndice is Iterable<*>){
                its = (currentIndice as Iterable<${ctx.getKevoreeContainer().get()}>).iterator();
                currentObj = null;
            }
            if(currentIndice is ${ctx.getKevoreeContainer().get()}){
                currentObj = currentIndice as ${ctx.getKevoreeContainer().get()} ;
                its = null;
            }
            return hasNext();
         }
    }

    override fun next() : ${ctx.getKevoreeContainer().get()} {
        if(hasNext()){
            if(currentObj != null){
                var result : ${ctx.getKevoreeContainer().get()} = currentObj!!
                currentObj = null;
                return result;
            } else {
                if (its != null && its!!.hasNext()) {
                    return its!!.next();
                } else {
                    throw Exception();
                }
            }
        } else {
            throw Exception();
        }
    }

#if(!$ctx.jS)override#end public fun remove() {
        throw java.lang.UnsupportedOperationException();
    }

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy