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

org.dmg.pmml.VisitContext Maven / Gradle / Ivy

There is a newer version: 1.6.6
Show newest version
/*
 * 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();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy