1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.maven.model;
17
18 import org.kuali.common.util.Assert;
19 import org.kuali.common.util.nullify.NullUtils;
20
21 import com.google.common.base.Optional;
22
23
24
25
26 public final class Dependency {
27
28 private final String groupId;
29 private final String artifactId;
30 private final String version;
31 private final Optional<String> classifier;
32
33
34
35 private final String type;
36 private final String scope;
37
38 public String getGroupId() {
39 return groupId;
40 }
41
42 public String getArtifactId() {
43 return artifactId;
44 }
45
46 public String getVersion() {
47 return version;
48 }
49
50 public Optional<String> getClassifier() {
51 return classifier;
52 }
53
54 public String getType() {
55 return type;
56 }
57
58 public String getScope() {
59 return scope;
60 }
61
62 public static class Builder {
63
64 public static final String DEFAULT_TYPE = Artifact.Builder.DEFAULT_TYPE;
65 public static final String DEFAULT_SCOPE = "compile";
66
67
68 private final String groupId;
69 private final String artifactId;
70 private final String version;
71
72
73 private Optional<String> classifier = Optional.absent();
74 private String type = DEFAULT_TYPE;
75 private String scope = DEFAULT_SCOPE;
76
77 public Builder(String groupId, String artifactId, String version) {
78 this.groupId = groupId;
79 this.artifactId = artifactId;
80 this.version = version;
81 }
82
83 public Builder classifier(String classifier) {
84 this.classifier = Optional.fromNullable(NullUtils.trimToNull(classifier));
85 return this;
86 }
87
88 public Builder type(String type) {
89 this.type = type;
90 return this;
91 }
92
93 public Builder scope(String scope) {
94 this.scope = scope;
95 return this;
96 }
97
98 public Dependency build() {
99 Assert.noBlanks(groupId, artifactId, version, type, scope);
100 Assert.noNulls(classifier);
101 return new Dependency(this);
102 }
103 }
104
105 private Dependency(Builder builder) {
106 this.groupId = builder.groupId;
107 this.artifactId = builder.artifactId;
108 this.version = builder.version;
109 this.classifier = builder.classifier;
110 this.type = builder.type;
111 this.scope = builder.scope;
112 }
113
114 }