1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.internal.impl.resolution;
20
21 import java.util.List;
22
23 import org.eclipse.aether.RepositorySystemSession;
24 import org.eclipse.aether.resolution.ArtifactResult;
25 import org.eclipse.aether.spi.resolution.ArtifactResolverPostProcessor;
26 import org.eclipse.aether.util.ConfigUtils;
27
28 import static java.util.Objects.requireNonNull;
29
30
31
32
33
34
35 public abstract class ArtifactResolverPostProcessorSupport implements ArtifactResolverPostProcessor {
36 private static final String CONFIG_PROP_PREFIX = "aether.artifactResolver.postProcessor.";
37
38 private final String name;
39
40 protected ArtifactResolverPostProcessorSupport(String name) {
41 this.name = requireNonNull(name);
42 }
43
44
45
46
47 @Override
48 public void postProcess(RepositorySystemSession session, List<ArtifactResult> artifactResults) {
49 if (isEnabled(session)) {
50 doPostProcess(session, artifactResults);
51 }
52 }
53
54 protected abstract void doPostProcess(RepositorySystemSession session, List<ArtifactResult> artifactResults);
55
56
57
58
59 protected String configPropKey(String name) {
60 requireNonNull(name);
61 return CONFIG_PROP_PREFIX + this.name + "." + name;
62 }
63
64
65
66
67
68
69 protected boolean isEnabled(RepositorySystemSession session) {
70 return ConfigUtils.getBoolean(session, false, CONFIG_PROP_PREFIX + this.name);
71 }
72 }