1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.impl.scope;
20
21 import java.util.Arrays;
22 import java.util.Collections;
23 import java.util.HashSet;
24 import java.util.Objects;
25 import java.util.Set;
26
27
28
29
30
31
32 public final class CommonBuilds {
33 private CommonBuilds() {}
34
35 private abstract static class Label {
36 private final String id;
37
38 protected Label(String id) {
39 this.id = id;
40 }
41
42 public String getId() {
43 return id;
44 }
45
46 @Override
47 public boolean equals(Object o) {
48 if (this == o) {
49 return true;
50 }
51 if (o == null || getClass() != o.getClass()) {
52 return false;
53 }
54 Label label = (Label) o;
55 return Objects.equals(id, label.id);
56 }
57
58 @Override
59 public int hashCode() {
60 return Objects.hash(id);
61 }
62
63 @Override
64 public String toString() {
65 return id;
66 }
67 }
68
69 private static final class ProjectPathImpl extends Label implements ProjectPath {
70 private final int order;
71 private final int reverseOrder;
72
73 private ProjectPathImpl(String id, int order, int reverseOrder) {
74 super(id);
75 this.order = order;
76 this.reverseOrder = reverseOrder;
77 }
78
79 @Override
80 public int order() {
81 return order;
82 }
83
84 @Override
85 public int reverseOrder() {
86 return reverseOrder;
87 }
88 }
89
90 private static final class BuildPathImpl extends Label implements BuildPath {
91 private final boolean reverse;
92 private final int order;
93
94 private BuildPathImpl(String id, boolean reverse, int order) {
95 super(id);
96 this.reverse = reverse;
97 this.order = order;
98 }
99
100 @Override
101 public boolean isReverse() {
102 return reverse;
103 }
104
105 @Override
106 public int order() {
107 return order;
108 }
109 }
110
111 private static final class BuildScopeImpl extends Label implements BuildScope {
112 private final Set<ProjectPath> projectPaths;
113 private final Set<BuildPath> buildPaths;
114 private final int order;
115
116 private BuildScopeImpl(String id, Set<ProjectPath> projectPaths, Set<BuildPath> buildPaths, int order) {
117 super(id);
118 this.projectPaths = projectPaths;
119 this.buildPaths = buildPaths;
120 this.order = order;
121 }
122
123 @Override
124 public Set<ProjectPath> getProjectPaths() {
125 return projectPaths;
126 }
127
128 @Override
129 public Set<BuildPath> getBuildPaths() {
130 return buildPaths;
131 }
132
133 @Override
134 public int order() {
135 return order;
136 }
137 }
138
139
140
141
142 public static final ProjectPath PROJECT_PATH_MAIN = new ProjectPathImpl("main", 1, 3);
143
144
145
146
147 public static final ProjectPath PROJECT_PATH_TEST = new ProjectPathImpl("test", 2, 1);
148
149
150
151
152 public static final ProjectPath PROJECT_PATH_IT = new ProjectPathImpl("it", 3, 2);
153
154
155
156
157 public static final BuildPath BUILD_PATH_PREPROCESS = new BuildPathImpl("preprocess", false, 1);
158
159
160
161
162 public static final BuildPath BUILD_PATH_COMPILE = new BuildPathImpl("compile", false, 2);
163
164
165
166
167 public static final BuildPath BUILD_PATH_RUNTIME = new BuildPathImpl("runtime", true, 3);
168
169
170
171
172
173 public static final BuildScope MAVEN_TEST_BUILD_SCOPE = new BuildScopeImpl(
174 "test",
175 Collections.singleton(PROJECT_PATH_TEST),
176 Collections.unmodifiableSet(new HashSet<>(Arrays.asList(BUILD_PATH_COMPILE, BUILD_PATH_RUNTIME))),
177 10);
178 }