17
17
package org .jfrog .build .api ;
18
18
19
19
import com .thoughtworks .xstream .annotations .XStreamAlias ;
20
+ import org .apache .commons .lang .ArrayUtils ;
21
+ import org .apache .commons .lang .StringUtils ;
20
22
21
- import java .util .Collection ;
22
- import java .util .Collections ;
23
- import java .util .List ;
24
- import java .util .Optional ;
23
+ import java .util .*;
25
24
import java .util .stream .Collectors ;
26
25
import java .util .stream .Stream ;
27
26
35
34
@ XStreamAlias (MODULE )
36
35
public class Module extends BaseBuildBean {
37
36
37
+ private String type ;
38
+
38
39
private String id ;
39
40
41
+ private String repository ;
42
+
43
+ private String md5 ;
44
+
45
+ private String sha1 ;
46
+
40
47
@ XStreamAlias (ARTIFACTS )
41
48
private List <Artifact > artifacts ;
42
49
@@ -46,6 +53,24 @@ public class Module extends BaseBuildBean {
46
53
@ XStreamAlias (DEPENDENCIES )
47
54
private List <Dependency > dependencies ;
48
55
56
+ /**
57
+ * Returns the type of the module
58
+ *
59
+ * @return Module type
60
+ */
61
+ public String getType () {
62
+ return type ;
63
+ }
64
+
65
+ /**
66
+ * Sets the type of the module
67
+ *
68
+ * @param type Module type
69
+ */
70
+ public void setType (String type ) {
71
+ this .type = type ;
72
+ }
73
+
49
74
/**
50
75
* Returns the ID of the module
51
76
*
@@ -64,6 +89,60 @@ public void setId(String id) {
64
89
this .id = id ;
65
90
}
66
91
92
+ /**
93
+ * Sets the repository of the module
94
+ *
95
+ * @param repository Module repository
96
+ */
97
+ public void setRepository (String repository ) {
98
+ this .repository = repository ;
99
+ }
100
+
101
+ /**
102
+ * Returns the repository of the module
103
+ *
104
+ * @return Module repository
105
+ */
106
+ public String getRepository () {
107
+ return repository ;
108
+ }
109
+
110
+ /**
111
+ * Sets the sha1 of the module
112
+ *
113
+ * @param sha1 Module sha1
114
+ */
115
+ public void setSha1 (String sha1 ) {
116
+ this .sha1 = sha1 ;
117
+ }
118
+
119
+ /**
120
+ * Returns the sha1 of the module
121
+ *
122
+ * @return Module sha1
123
+ */
124
+ public String getSha1 () {
125
+ return sha1 ;
126
+ }
127
+
128
+ /**
129
+ * Sets the md5 of the module
130
+ *
131
+ * @param md5 Module md5
132
+ */
133
+ public void setMd5 (String md5 ) {
134
+ this .md5 = md5 ;
135
+ }
136
+
137
+ /**
138
+ * Returns the md5 of the module
139
+ *
140
+ * @return Module md5
141
+ */
142
+ public String getMd5 () {
143
+ return md5 ;
144
+ }
145
+
67
146
/**
68
147
* Returns the list of artifacts that have been deployed by the module
69
148
*
@@ -127,6 +206,10 @@ public void append(Module other) {
127
206
artifacts = appendBuildFileLists (artifacts , other .getArtifacts ());
128
207
excludedArtifacts = appendBuildFileLists (excludedArtifacts , other .getExcludedArtifacts ());
129
208
dependencies = appendBuildFileLists (dependencies , other .getDependencies ());
209
+ type = StringUtils .defaultIfEmpty (type , other .type );
210
+ repository = StringUtils .defaultIfEmpty (repository , other .repository );
211
+ md5 = StringUtils .defaultIfEmpty (md5 , other .md5 );
212
+ sha1 = StringUtils .defaultIfEmpty (sha1 , other .sha1 );
130
213
}
131
214
132
215
private <T extends BaseBuildBean > List <T > appendBuildFileLists (List <T > a , List <T > b ) {
@@ -141,26 +224,27 @@ private <T extends BaseBuildBean> List<T> appendBuildFileLists(List<T> a, List<T
141
224
142
225
@ Override
143
226
public boolean equals (Object o ) {
144
- if (this == o ) return true ;
145
- if (o == null || getClass () != o .getClass ()) return false ;
227
+ if (this == o ) {
228
+ return true ;
229
+ }
230
+ if (o == null || getClass () != o .getClass ()) {
231
+ return false ;
232
+ }
146
233
147
234
Module module = (Module ) o ;
148
235
149
- if (getId () != null ? !getId ().equals (module .getId ()) : module .getId () != null ) return false ;
150
- if (getArtifacts () != null ? !getArtifacts ().equals (module .getArtifacts ()) : module .getArtifacts () != null )
151
- return false ;
152
- if (getExcludedArtifacts () != null ? !getExcludedArtifacts ().equals (module .getExcludedArtifacts ()) : module .getExcludedArtifacts () != null )
153
- return false ;
154
- return getDependencies () != null ? getDependencies ().equals (module .getDependencies ()) : module .getDependencies () == null ;
155
-
236
+ return StringUtils .equals (getType (), module .getType ()) &&
237
+ StringUtils .equals (getId (), module .getId ()) &&
238
+ StringUtils .equals (getRepository (), module .getRepository ()) &&
239
+ StringUtils .equals (getSha1 (), module .getSha1 ()) &&
240
+ StringUtils .equals (getMd5 (), module .getMd5 ()) &&
241
+ ArrayUtils .isEquals (getArtifacts (), module .getArtifacts ()) &&
242
+ ArrayUtils .isEquals (getExcludedArtifacts (), module .getExcludedArtifacts ()) &&
243
+ ArrayUtils .isEquals (getDependencies (), module .getDependencies ());
156
244
}
157
245
158
246
@ Override
159
247
public int hashCode () {
160
- int result = getId () != null ? getId ().hashCode () : 0 ;
161
- result = 31 * result + (getArtifacts () != null ? getArtifacts ().hashCode () : 0 );
162
- result = 31 * result + (getExcludedArtifacts () != null ? getExcludedArtifacts ().hashCode () : 0 );
163
- result = 31 * result + (getDependencies () != null ? getDependencies ().hashCode () : 0 );
164
- return result ;
248
+ return Objects .hash (getType (), getId (), getRepository (), getSha1 (), getMd5 (), getArtifacts (), getExcludedArtifacts (), getDependencies ());
165
249
}
166
250
}
0 commit comments