1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.internal.aether;
20
21 import org.apache.maven.api.PathType;
22 import org.apache.maven.api.Type;
23 import org.apache.maven.api.services.TypeRegistry;
24 import org.apache.maven.repository.internal.type.DefaultType;
25 import org.eclipse.aether.artifact.ArtifactType;
26 import org.eclipse.aether.artifact.ArtifactTypeRegistry;
27
28 import static java.util.Objects.requireNonNull;
29
30 class TypeRegistryAdapter implements ArtifactTypeRegistry {
31 private final TypeRegistry typeRegistry;
32
33 TypeRegistryAdapter(TypeRegistry typeRegistry) {
34 this.typeRegistry = requireNonNull(typeRegistry, "typeRegistry");
35 }
36
37 @Override
38 public ArtifactType get(String typeId) {
39 Type type = typeRegistry.require(typeId);
40 if (type instanceof ArtifactType) {
41 return (ArtifactType) type;
42 }
43 if (type != null) {
44 return new DefaultType(
45 type.id(),
46 type.getLanguage(),
47 type.getExtension(),
48 type.getClassifier(),
49 type.isIncludesDependencies(),
50 type.getPathTypes().toArray(new PathType[0]));
51 }
52 return null;
53 }
54 }