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 @Deprecated
41 private boolean addedToClasspath;
42
43
44
45
46
47
48
49 @Deprecated
50 public DefaultArtifactHandler() {
51 this.type = null;
52 }
53
54 public DefaultArtifactHandler(final String type) {
55 this(type, null, null, null, null, false, null, false);
56 }
57
58 @SuppressWarnings("checkstyle:ParameterNumber")
59 public DefaultArtifactHandler(
60 final String type,
61 final String extension,
62 final String classifier,
63 final String directory,
64 final String packaging,
65 final boolean includesDependencies,
66 final String language,
67 final boolean addedToClasspath) {
68 this.type = requireNonNull(type);
69 this.extension = extension;
70 this.classifier = classifier;
71 this.directory = directory;
72 this.packaging = packaging;
73 this.includesDependencies = includesDependencies;
74 this.language = language;
75 this.addedToClasspath = addedToClasspath;
76 }
77
78 public String getType() {
79 return type;
80 }
81
82 @Override
83 public String getExtension() {
84 if (extension == null) {
85 return type;
86 }
87 return extension;
88 }
89
90 public void setExtension(final String extension) {
91 this.extension = extension;
92 }
93
94 @Override
95 public String getClassifier() {
96 return classifier;
97 }
98
99 public void setClassifier(final String classifier) {
100 this.classifier = classifier;
101 }
102
103 @Override
104 public String getDirectory() {
105 if (directory == null) {
106 return getPackaging() + "s";
107 }
108 return directory;
109 }
110
111 public void setDirectory(final String directory) {
112 this.directory = directory;
113 }
114
115 @Override
116 public String getPackaging() {
117 if (packaging == null) {
118 return type;
119 }
120 return packaging;
121 }
122
123 public void setPackaging(final String packaging) {
124 this.packaging = packaging;
125 }
126
127 @Override
128 public boolean isIncludesDependencies() {
129 return includesDependencies;
130 }
131
132 public void setIncludesDependencies(final boolean includesDependencies) {
133 this.includesDependencies = includesDependencies;
134 }
135
136 @Override
137 public String getLanguage() {
138 if (language == null) {
139 return "none";
140 }
141
142 return language;
143 }
144
145 public void setLanguage(final String language) {
146 this.language = language;
147 }
148
149 @Override
150 @Deprecated
151 public boolean isAddedToClasspath() {
152 return addedToClasspath;
153 }
154
155 @Deprecated
156 public void setAddedToClasspath(final boolean addedToClasspath) {
157 this.addedToClasspath = addedToClasspath;
158 }
159 }