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

com.almondtools.util.graph.GraphNode Maven / Gradle / Ivy

Go to download

Regular expression matchers, searcher, lexers based on deterministic finite automata

There is a newer version: 0.3.3
Show newest version
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