1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.artifact.handler;
20
21 import static java.util.Objects.requireNonNull;
22
23
24
25 public class DefaultArtifactHandler implements ArtifactHandler {
26 private final String type;
27
28 private String extension;
29
30 private String classifier;
31
32 private String directory;
33
34 private String packaging;
35
36 private boolean includesDependencies;
37
38 private String language;
39
40 private boolean addedToClasspath;
41
42
43
44
45
46
47
48 @Deprecated
49 public DefaultArtifactHandler() {
50 this.type = null;
51 }
52
53 public DefaultArtifactHandler(final String type) {
54 this(type, null, null, null, null, false, null, false);
55 }
56
57 @SuppressWarnings("checkstyle:ParameterNumber")
58 public DefaultArtifactHandler(
59 final String type,
60 final String extension,
61 final String classifier,
62 final String directory,
63 final String packaging,
64 final boolean includesDependencies,
65 final String language,
66 final boolean addedToClasspath) {
67 this.type = requireNonNull(type);
68 this.extension = extension;
69 this.classifier = classifier;
70 this.directory = directory;
71 this.packaging = packaging;
72 this.includesDependencies = includesDependencies;
73 this.language = language;
74 this.addedToClasspath = addedToClasspath;
75 }
76
77 public String getType() {
78 return type;
79 }
80
81 @Override
82 public String getExtension() {
83 if (extension == null) {
84 return type;
85 }
86 return extension;
87 }
88
89 public void setExtension(final String extension) {
90 this.extension = extension;
91 }
92
93 @Override
94 public String getClassifier() {
95 return classifier;
96 }
97
98 public void setClassifier(final String classifier) {
99 this.classifier = classifier;
100 }
101
102 @Override
103 public String getDirectory() {
104 if (directory == null) {
105 return getPackaging() + "s";
106 }
107 return directory;
108 }
109
110 public void setDirectory(final String directory) {
111 this.directory = directory;
112 }
113
114 @Override
115 public String getPackaging() {
116 if (packaging == null) {
117 return type;
118 }
119 return packaging;
120 }
121
122 public void setPackaging(final String packaging) {
123 this.packaging = packaging;
124 }
125
126 @Override
127 public boolean isIncludesDependencies() {
128 return includesDependencies;
129 }
130
131 public void setIncludesDependencies(final boolean includesDependencies) {
132 this.includesDependencies = includesDependencies;
133 }
134
135 @Override
136 public String getLanguage() {
137 if (language == null) {
138 return "none";
139 }
140
141 return language;
142 }
143
144 public void setLanguage(final String language) {
145 this.language = language;
146 }
147
148 @Override
149 public boolean isAddedToClasspath() {
150 return addedToClasspath;
151 }
152
153 public void setAddedToClasspath(final boolean addedToClasspath) {
154 this.addedToClasspath = addedToClasspath;
155 }
156 }