org.dmg.pmml.VisitContext Maven / Gradle / Ivy
/*
* Copyright (c) 2018 Villu Ruusmann
*/
package org.dmg.pmml;
import java.util.Deque;
import java.util.Iterator;
interface VisitContext {
Deque getParents();
default
public boolean hasParent(){
Deque parents = getParents();
return !parents.isEmpty();
}
default
public PMMLObject getParent(){
Deque parents = getParents();
return parents.getFirst();
}
default
public PMMLObject getParent(int index){
Deque parents = getParents();
if(index < 0){
throw new IllegalArgumentException();
}
Iterator it = parents.iterator();
for(int i = 0; i < index; i++){
it.next();
}
return it.next();
}
default
public void pushParent(PMMLObject parent){
Deque parents = getParents();
parents.addFirst(parent);
}
default
public PMMLObject popParent(){
Deque parents = getParents();
return parents.removeFirst();
}
}