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

net.ericaro.diezel.core.builder.State Maven / Gradle / Ivy

The newest version!
package net.ericaro.diezel.core.builder;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import edu.uci.ics.jung.graph.DirectedGraph;

/** represent a state in the EDSL, i.e. an interface with methods
 * 
 * @author eric
 *
 */
public class State {

	
	String name;
	List generics = new ArrayList();
	boolean isOutput = false;
	private DirectedGraph graph;
	private boolean input;
	
	
	State(DirectedGraph graph, String name, boolean input, boolean output) {
		super();
		this.graph = graph;
		this.isOutput = output;
		this.input = input;
		this.name = name;
	}
	
	public String getName() {
		return name;
	}

	String asJavaType(){
		StringBuilder sb = new StringBuilder();
		sb.append(name);
		if (generics!=null && generics.size() > 0 ){
			sb.append("<");
			StringUtils.join(",", generics, sb);
			sb.append(">");
		}
		return sb.toString() ;
	}

	public List getGenerics() {
		return generics;
	}

	

	public boolean isInput() {
		return input;
	}

	public boolean isOutput() {
		return isOutput;
	}
	
	/** to dot graphiz protocol
	 * 
	 * @return
	 */
	public String toString(){
			StringBuilder sb = new StringBuilder();
			sb.append(getName()).append("[shape=component,label=\"" + asJavaType() + "\"]");
			return sb.toString();
	}
	
	public Collection getTransitions(){
		return graph.getOutEdges(this);
	}
	
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy