1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.googlecode.t7mp;
17
18 import java.io.File;
19
20 import org.apache.commons.lang.StringUtils;
21
22
23
24
25
26
27 public abstract class AbstractArtifact {
28
29
30
31
32
33
34 protected String groupId;
35
36
37
38
39
40
41 protected String artifactId;
42
43
44
45
46
47 protected String version;
48
49
50
51
52
53 protected String type;
54
55
56
57
58
59 protected String classifier;
60
61
62
63
64
65 protected String systemPath;
66
67 protected File file;
68
69 public AbstractArtifact() {
70
71 }
72
73 public AbstractArtifact(String groupId, String artifactId, String version, String classifier, String type) {
74 this.setGroupId(groupId);
75 this.setArtifactId(artifactId);
76 this.setVersion(version);
77 this.setClassifier(classifier);
78 this.setType(type);
79
80 }
81
82 public String getGroupId() {
83 return groupId;
84 }
85
86 public void setGroupId(String groupId) {
87 this.groupId = groupId;
88 }
89
90 public String getArtifactId() {
91 return artifactId;
92 }
93
94 public void setArtifactId(String artifactId) {
95 this.artifactId = artifactId;
96 }
97
98 public String getVersion() {
99 return version;
100 }
101
102 public void setVersion(String version) {
103 this.version = version;
104 }
105
106 public abstract String getType();
107
108 public void setType(String type) {
109 this.type = type;
110 }
111
112 public String getClassifier() {
113 return classifier;
114 }
115
116 public void setClassifier(String classifier) {
117 this.classifier = classifier;
118 }
119
120 public String getSystemPath() {
121 return this.systemPath;
122 }
123
124 public void setSystemPath(String systemPath) {
125 this.systemPath = systemPath;
126 }
127
128 public File getFile() {
129 return file;
130 }
131
132 public void setFile(File file) {
133 this.file = file;
134 }
135
136 public String getArtifactCoordinates() {
137 if (!StringUtils.isBlank(getSystemPath())) {
138 return getSystemPath();
139 } else {
140 return buildDefaultMavenCoordinates();
141 }
142 }
143
144
145
146
147
148 protected String buildDefaultMavenCoordinates() {
149 StringBuilder sb = new StringBuilder();
150 sb.append(getGroupId()).append(":");
151 sb.append(getArtifactId());
152 if (StringUtils.isNotBlank(getType())) {
153 sb.append(":").append(getType());
154 }
155 if (StringUtils.isNotBlank(getClassifier())) {
156 sb.append(":").append(getClassifier());
157 }
158 sb.append(":");
159 sb.append(getVersion());
160 return sb.toString().trim();
161 }
162
163 @Override
164 public String toString() {
165 return "Artifact[" + getArtifactCoordinates() + "]";
166 }
167
168 }