Fix wrong edges being provided
@@ -36,10 +36,16 @@ public class ClassVertex extends Vertex<ClassNode> {
@Override
public boolean equals(Object other) {
+ if (other == null)
+ throw new IllegalStateException();
if (this == other)
return true;
- if (getData().equals(other))
+ if(other instanceof ClassVertex) {
+ ClassVertex otherVertex = (ClassVertex) other;
+ // TODO: Will ClassNode#equals work in all cases?
+ if(getData().equals(otherVertex.getData()))
return true;
+ }
return false;
}
@@ -51,14 +57,17 @@ public class ClassVertex extends Vertex<ClassNode> {
@Override
public Set<Edge<ClassNode>> getEdges() {
// Get names of parents/children
- Stream<String> parents = graph.getAllParents(getData().name);
- Stream<String> children = graph.getAllDescendants(getData().name);
+ Stream<String> parents = graph.getParents(getData().name);
+ Stream<String> children = graph.getDescendants(getData().name);
// Get values of parents/children
Stream<ClassNode> parentValues = getNodesFromNames(parents);
Stream<ClassNode> childrenValues = getNodesFromNames(children);
// Get edges of parents/children
Stream<Edge<ClassNode>> parentEdges = parentValues.map(node -> {
ClassVertex other = graph.getRoot(node.name);
+ if(other == null) {
+ other = new ClassVertex(graph, node);
+ }
return new DirectedEdge<>(other, ClassVertex.this);
});
Stream<Edge<ClassNode>> childrenEdges = childrenValues.map(node -> {
@@ -70,6 +79,8 @@ public class ClassVertex extends Vertex<ClassNode> {
.collect(Collectors.toSet());
}
+ // ============================== UTILITY =================================== //
+
/**
* @param names
* Stream of names of classes.
@@ -92,8 +103,6 @@ public class ClassVertex extends Vertex<ClassNode> {
}).filter(node -> node != null);
}
- // ============================== UTILITY =================================== //
-
/**
* @param name
* Internal class name.
