com.almondtools.util.graph.GraphNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rexlex Show documentation
Show all versions of rexlex Show documentation
Regular expression matchers, searcher, lexers based on deterministic finite automata
package com.almondtools.util.graph;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class GraphNode {
private K key;
private Map, Object> data;
private List> predecessors;
private List> successors;
public GraphNode(K key) {
this.key = key;
this.data = new HashMap, Object>();
this.predecessors = new LinkedList>();
this.successors = new LinkedList>();
}
public K getKey() {
return key;
}
public T getData(Class clazz) {
return clazz.cast(data.get(clazz));
}
public void setData(Object data) {
this.data.put(data.getClass(), data);
}
public void addPredecessor(GraphNode pre) {
if (!predecessors.contains(pre)) {
predecessors.add(pre);
}
}
public List> getPredecessors() {
return predecessors;
}
public void addSuccessor(GraphNode suc) {
if (!successors.contains(suc)) {
successors.add(suc);
}
}
public List> getSuccessors() {
return successors;
}
public void apply(Traversal traversal) {
traversal.traverseNode(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy