1
2
3
4
5
6
7
8
9
10
11
12
13 package org.abstracthorizon.extend.repository.maven.pom;
14
15 import org.abstracthorizon.extend.server.deployment.ModuleId;
16
17 public class Artifact extends ModuleId {
18
19 public Artifact() {
20 }
21
22 public Artifact(ModuleId copy) {
23 super(copy);
24 }
25
26 public Artifact(Artifact copy) {
27 super(copy);
28 }
29
30 public String toString(int indent) {
31 StringBuffer res = new StringBuffer();
32 if (groupId != null) {
33 ToStringHelper.valueTag("groupId", groupId, res, indent);
34 }
35 if (artifactId != null) {
36 ToStringHelper.valueTag("artifactId", artifactId, res, indent);
37 }
38 if (version != null) {
39 ToStringHelper.valueTag("version", version, res, indent);
40 }
41 if (type != null) {
42 ToStringHelper.valueTag("type", type, res, indent);
43 }
44 if (classifier != null) {
45 ToStringHelper.valueTag("classifier", classifier, res, indent);
46 }
47 return res.toString();
48 }
49
50
51
52
53
54 public Artifact toPOMArtifact() {
55 if ("pom".equals(type)) {
56 return this;
57 } else {
58 Artifact pomArtifact = new Artifact(this);
59 pomArtifact.setType("pom");
60 pomArtifact.classifier = null;
61 return pomArtifact;
62 }
63 }
64
65 public Artifact toSnapshotArtifact() {
66 if (version.toUpperCase().endsWith("-SNAPSHOT")) {
67 return this;
68 } else {
69 Artifact snapshot = new Artifact(this);
70 snapshot.setVersion(version + "-SNAPSHOT");
71 return snapshot;
72 }
73 }
74
75 public Artifact toNonSnapshotArtifact() {
76 if (!version.toUpperCase().endsWith("-SNAPSHOT")) {
77 return this;
78 } else {
79 Artifact notSnapshot = new Artifact(this);
80 notSnapshot.setVersion(version.substring(0, version.length() - 9));
81 return notSnapshot;
82 }
83 }
84
85 }