odeling.org.kevoree.modeling.kotlin.generator.1.5.3.source-code.CompositeIterator.vm Maven / Gradle / Ivy
#* @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