1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.repository.internal.type;
20
21 import java.util.Arrays;
22 import java.util.Collections;
23 import java.util.HashMap;
24 import java.util.HashSet;
25 import java.util.Map;
26 import java.util.Set;
27
28 import org.apache.maven.api.JavaPathType;
29 import org.apache.maven.api.Language;
30 import org.apache.maven.api.PathType;
31 import org.apache.maven.api.Type;
32 import org.apache.maven.repository.internal.artifact.MavenArtifactProperties;
33 import org.eclipse.aether.artifact.ArtifactProperties;
34 import org.eclipse.aether.artifact.ArtifactType;
35
36 import static java.util.Objects.requireNonNull;
37
38
39
40
41
42
43
44 @Deprecated(since = "4.0.0")
45 public class DefaultType implements Type, ArtifactType {
46 private final String id;
47 private final Language language;
48 private final String extension;
49 private final String classifier;
50 private final boolean includesDependencies;
51 private final Set<PathType> pathTypes;
52 private final Map<String, String> properties;
53
54 public DefaultType(
55 String id,
56 Language language,
57 String extension,
58 String classifier,
59 boolean includesDependencies,
60 PathType... pathTypes) {
61 this.id = requireNonNull(id, "id");
62 this.language = requireNonNull(language, "language");
63 this.extension = requireNonNull(extension, "extension");
64 this.classifier = classifier;
65 this.includesDependencies = includesDependencies;
66 this.pathTypes = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(pathTypes)));
67
68 Map<String, String> properties = new HashMap<>();
69 properties.put(ArtifactProperties.TYPE, id);
70 properties.put(ArtifactProperties.LANGUAGE, language.id());
71 properties.put(MavenArtifactProperties.INCLUDES_DEPENDENCIES, Boolean.toString(includesDependencies));
72 properties.put(
73 MavenArtifactProperties.CONSTITUTES_BUILD_PATH,
74 String.valueOf(this.pathTypes.contains(JavaPathType.CLASSES)));
75 this.properties = Collections.unmodifiableMap(properties);
76 }
77
78 @Override
79 public String id() {
80 return id;
81 }
82
83 @Override
84 public String getId() {
85 return id();
86 }
87
88 @Override
89 public Language getLanguage() {
90 return language;
91 }
92
93 @Override
94 public String getExtension() {
95 return extension;
96 }
97
98 @Override
99 public String getClassifier() {
100 return classifier;
101 }
102
103 @Override
104 public boolean isIncludesDependencies() {
105 return this.includesDependencies;
106 }
107
108 @Override
109 public Set<PathType> getPathTypes() {
110 return this.pathTypes;
111 }
112
113 @Override
114 public Map<String, String> getProperties() {
115 return properties;
116 }
117 }