equal
deleted
inserted
replaced
29 import java.util.ArrayDeque; |
29 import java.util.ArrayDeque; |
30 import java.util.ArrayList; |
30 import java.util.ArrayList; |
31 import java.util.Collection; |
31 import java.util.Collection; |
32 import java.util.Collections; |
32 import java.util.Collections; |
33 import java.util.Deque; |
33 import java.util.Deque; |
34 import java.util.HashMap; |
|
35 import java.util.HashSet; |
34 import java.util.HashSet; |
36 import java.util.List; |
35 import java.util.List; |
37 import java.util.Map; |
36 import java.util.Map; |
38 import java.util.Map.Entry; |
37 import java.util.Map.Entry; |
39 import java.util.Objects; |
38 import java.util.Objects; |
117 private final String targetPlatform; |
116 private final String targetPlatform; |
118 |
117 |
119 String targetPlatform() { return targetPlatform; } |
118 String targetPlatform() { return targetPlatform; } |
120 |
119 |
121 private Configuration() { |
120 private Configuration() { |
122 this.parents = Collections.emptyList(); |
121 this.parents = List.of(); |
123 this.graph = Collections.emptyMap(); |
122 this.graph = Map.of(); |
124 this.modules = Collections.emptySet(); |
123 this.modules = Set.of(); |
125 this.nameToModule = Collections.emptyMap(); |
124 this.nameToModule = Map.of(); |
126 this.targetPlatform = null; |
125 this.targetPlatform = null; |
127 } |
126 } |
128 |
127 |
129 private Configuration(List<Configuration> parents, Resolver resolver) { |
128 private Configuration(List<Configuration> parents, Resolver resolver) { |
130 Map<ResolvedModule, Set<ResolvedModule>> g = resolver.finish(this); |
129 Map<ResolvedModule, Set<ResolvedModule>> g = resolver.finish(this); |
138 moduleArray[i] = resolvedModule; |
137 moduleArray[i] = resolvedModule; |
139 nameEntries[i] = Map.entry(resolvedModule.name(), resolvedModule); |
138 nameEntries[i] = Map.entry(resolvedModule.name(), resolvedModule); |
140 i++; |
139 i++; |
141 } |
140 } |
142 |
141 |
143 this.parents = Collections.unmodifiableList(parents); |
142 this.parents = List.copyOf(parents); |
144 this.graph = g; |
143 this.graph = g; |
145 this.modules = Set.of(moduleArray); |
144 this.modules = Set.of(moduleArray); |
146 this.nameToModule = Map.ofEntries(nameEntries); |
145 this.nameToModule = Map.ofEntries(nameEntries); |
147 |
146 |
148 this.targetPlatform = resolver.targetPlatform(); |
147 this.targetPlatform = resolver.targetPlatform(); |
552 } |
551 } |
553 |
552 |
554 |
553 |
555 Set<ModuleDescriptor> descriptors() { |
554 Set<ModuleDescriptor> descriptors() { |
556 if (modules.isEmpty()) { |
555 if (modules.isEmpty()) { |
557 return Collections.emptySet(); |
556 return Set.of(); |
558 } else { |
557 } else { |
559 return modules.stream() |
558 return modules.stream() |
560 .map(ResolvedModule::reference) |
559 .map(ResolvedModule::reference) |
561 .map(ModuleReference::descriptor) |
560 .map(ModuleReference::descriptor) |
562 .collect(Collectors.toSet()); |
561 .collect(Collectors.toSet()); |
594 visited.add(parent); |
593 visited.add(parent); |
595 stack.push(parent); |
594 stack.push(parent); |
596 } |
595 } |
597 } |
596 } |
598 } |
597 } |
599 this.allConfigurations = Collections.unmodifiableList(allConfigurations); |
598 this.allConfigurations = allConfigurations; // no need to do defensive copy |
600 } |
599 } |
601 return allConfigurations.stream(); |
600 return allConfigurations.stream(); |
602 } |
601 } |
603 |
602 |
604 private volatile List<Configuration> allConfigurations; |
603 private volatile List<Configuration> allConfigurations; |