-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGroum.java
More file actions
executable file
·104 lines (86 loc) · 2.69 KB
/
Copy pathGroum.java
File metadata and controls
executable file
·104 lines (86 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Groum implements Serializable {
// private GroumNode root = null;
private Map<String, GroumNode> nodeMap = new HashMap<>();
private Map<Integer, List<GroumNode>> lineMap = new HashMap<>();
private List<GroumNode> nodes = new ArrayList<>();
private List<GroumNode> rootList = new ArrayList<>();
// public GroumNode getRoot() {
// return root;
// }
// public void setRoot(GroumNode root) {
// this.root = root;
// }
public Map<Integer, List<GroumNode>> getLineMap() {
return lineMap;
}
public void setLineMap(Map<Integer, List<GroumNode>> lineMap) {
this.lineMap = lineMap;
}
public Map<String, GroumNode> getNodeMap() {
return nodeMap;
}
public void setNodeMap(Map<String, GroumNode> nodeMap) {
this.nodeMap = nodeMap;
}
public List<GroumNode> getNodes() {
return nodes;
}
public void setNodes(List<GroumNode> nodes) {
this.nodes = nodes;
}
public void addNode(GroumNode node){
if (lineMap.containsKey(node.getStartLine())) {
lineMap.get(node.getStartLine()).add(node);
} else {
List<GroumNode> list = new ArrayList<>();
list.add(node);
lineMap.put(node.getStartLine(), list);
}
if(!nodes.contains(node)) {
nodes.add(node);
nodeMap.put(node.getId(), node);
}
}
public void addEdge(String parentNodeId, String childNodeId){
GroumNode parentNode = nodeMap.get(parentNodeId);
GroumNode childNode = nodeMap.get(childNodeId);
if(!parentNode.getChildren().contains(childNode)) {
parentNode.getChildren().add(childNode);
}
if(!childNode.getParents().contains(parentNode)) {
childNode.getParents().add(parentNode);
}
}
//
// public void setRoot(){
// for(GroumNode node: nodes){
// if(node.getParents().size() == 0){
// root = node;
// break;
// }
// }
// }
public List<GroumNode> getRootList(){
for(GroumNode node: nodes){
if(node.getParents().size() == 0){
if(!rootList.contains(node)) {
rootList.add(node);
}
}
}
return rootList;
}
public boolean isContainingJDKApi(Map<String,Boolean> jdkMap){
for(GroumNode node: nodes){
if(jdkMap.containsKey(node.getOriginalApi())){
return true;
}
}
return false;
}
}