65 if (set == null) { |
65 if (set == null) { |
66 set = new HashSet<>(); |
66 set = new HashSet<>(); |
67 deps.put(origin, set); |
67 deps.put(origin, set); |
68 } |
68 } |
69 } |
69 } |
|
70 |
70 public void addClass(Location origin, Location target) { |
71 public void addClass(Location origin, Location target) { |
71 Set<Location> set = deps.get(origin); |
72 Set<Location> set = deps.get(origin); |
72 if (set == null) { |
73 if (set == null) { |
73 set = new HashSet<>(); |
74 set = new HashSet<>(); |
74 deps.put(origin, set); |
75 deps.put(origin, set); |
75 } |
76 } |
76 set.add(target); |
77 set.add(target); |
77 } |
78 } |
78 |
79 |
79 public void visit(Visitor v) { |
80 public Set<Location> getClasses() { |
|
81 return deps.keySet(); |
|
82 } |
|
83 |
|
84 public void visitDependences(Visitor v) { |
80 for (Map.Entry<Location,Set<Location>> e: deps.entrySet()) { |
85 for (Map.Entry<Location,Set<Location>> e: deps.entrySet()) { |
81 v.visit(e.getKey()); |
|
82 for (Location target : e.getValue()) { |
86 for (Location target : e.getValue()) { |
83 v.visit(e.getKey(), target); |
87 v.visit(e.getKey(), target); |
84 } |
88 } |
85 } |
89 } |
86 } |
90 } |
87 |
91 |
88 public String toString() { |
92 public String getPathName() { |
89 return path != null ? path.toString() : filename; |
93 return path != null ? path.toString() : filename; |
90 } |
94 } |
91 |
95 |
|
96 public String toString() { |
|
97 return filename; |
|
98 } |
|
99 |
92 interface Visitor { |
100 interface Visitor { |
93 void visit(Location loc); |
|
94 void visit(Location origin, Location target); |
101 void visit(Location origin, Location target); |
95 } |
102 } |
96 } |
103 } |