1 package org.eclipse.aether.internal.impl.synccontext.named;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.eclipse.aether.RepositorySystemSession;
23 import org.eclipse.aether.artifact.Artifact;
24 import org.eclipse.aether.metadata.Metadata;
25 import org.eclipse.aether.util.ConfigUtils;
26
27 import javax.inject.Inject;
28 import javax.inject.Named;
29 import javax.inject.Singleton;
30 import java.util.Collection;
31 import java.util.Collections;
32 import java.util.Objects;
33
34
35
36
37 @Singleton
38 @Named( StaticNameMapper.NAME )
39 public class StaticNameMapper implements NameMapper
40 {
41 public static final String NAME = "static";
42
43
44
45
46 private static final String CONFIG_PROP_NAME = "aether.syncContext.named.static.name";
47
48 private final String name;
49
50
51
52
53 @Inject
54 public StaticNameMapper()
55 {
56 this( NAME );
57 }
58
59
60
61
62 public StaticNameMapper( final String name )
63 {
64 this.name = Objects.requireNonNull( name );
65 }
66
67 @Override
68 public Collection<String> nameLocks( final RepositorySystemSession session,
69 final Collection<? extends Artifact> artifacts,
70 final Collection<? extends Metadata> metadatas )
71 {
72 return Collections.singletonList( ConfigUtils.getString( session, name, CONFIG_PROP_NAME ) );
73 }
74 }