Commit 01554ccb authored by Roland Kluge's avatar Roland Kluge
Browse files

Implement a non-naive toString for DirectedEdge to avoid recursive calls

parent e811c67d
......@@ -23,6 +23,7 @@ package de.tudarmstadt.maki.simonstrator.api.common.graph;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import de.tudarmstadt.maki.simonstrator.api.Graphs;
import de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSType;
......@@ -185,10 +186,23 @@ public class DirectedEdge implements IEdge {
public String toString() {
return "DirectedEdge [" + (startNode != null ? startNode + " -> " : "")
+ (endNode != null ? endNode : "")
+ (properties != null ? ", properties=" + properties : "")
+ (properties != null ? ", properties=" + formatProperties() : "")
+ "]";
}
public String formatProperties() {
final StringBuilder builder = new StringBuilder();
for (final Entry<SiSType<?>, Object> entry : this.properties.entrySet()) {
if (entry.getKey().getType().isInstance(IEdge.class))
{
builder.append(String.format("%s, %s", entry.getKey().toString(), ((IEdge) entry.getValue()).getId()));
} else {
builder.append(String.format("%s, %s", entry.getKey().toString(), entry.getValue().toString()));
}
}
return builder.toString();
}
@Override
public int hashCode() {
final int prime = 31;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment