net.ericaro.diezel.core.builder.State Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of diezel-maven-plugin Show documentation
Show all versions of diezel-maven-plugin Show documentation
An Embedded Domain Specific Language Parser Generator PLugin compiler
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);
}
}