Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
API
Commits
01554ccb
Commit
01554ccb
authored
Nov 06, 2015
by
Roland Kluge
Browse files
Implement a non-naive toString for DirectedEdge to avoid recursive calls
parent
e811c67d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tudarmstadt/maki/simonstrator/api/common/graph/DirectedEdge.java
View file @
01554ccb
...
...
@@ -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="
+
p
roperties
:
""
)
+
(
properties
!=
null
?
", properties="
+
formatP
roperties
()
:
""
)
+
"]"
;
}
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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment