Skip to content

Commit 8e5f5c9

Browse files
committed
Merge remote-tracking branch 'origin/main' into pr_1208
2 parents 3a2e350 + 20fbf1a commit 8e5f5c9

18 files changed

+423
-200
lines changed

Diff for: README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ repositories {
7272
maven {
7373
url "https://jitpack.io"
7474
content {
75-
includeGroup "com.github.gitlab4j"
75+
includeGroup "com.github.gitlab4j.gitlab4j-api"
7676
}
7777
}
7878
}
7979
8080
dependencies {
8181
// ...
82-
implementation 'com.github.gitlab4j:gitlab4j-api:main-SNAPSHOT'
82+
implementation 'com.github.gitlab4j.gitlab4j-api:gitlab4j-api:main-SNAPSHOT'
8383
// ...
8484
}
8585
```
@@ -96,7 +96,7 @@ dependencies {
9696

9797
<dependencies>
9898
<dependency>
99-
<groupId>com.github.gitlab4j</groupId>
99+
<groupId>com.github.gitlab4j.gitlab4j-api</groupId>
100100
<artifactId>gitlab4j-api</artifactId>
101101
<version>main-SNAPSHOT</version>
102102
</dependency>
@@ -109,7 +109,7 @@ dependencies {
109109
You just need to declare the dependency like this, instead of using the maven coordinates:
110110

111111
```java
112-
//DEPS https://github.com/gitlab4j/gitlab4j-api/tree/main#:SNAPSHOT
112+
//DEPS https://github.com/gitlab4j/gitlab4j-api/tree/main#gitlab4j-api:SNAPSHOT
113113
```
114114

115115
**Using a specific commit**
@@ -119,20 +119,20 @@ You can also point to a specific commit:
119119

120120
```gradle
121121
dependencies {
122-
implementation 'com.github.gitlab4j:gitlab4j-api:7dfec10189'
122+
implementation 'com.github.gitlab4j.gitlab4j-api:gitlab4j-api:ab6b84c6b0'
123123
}
124124
```
125125

126126
```xml
127127
<dependency>
128-
<groupId>com.github.gitlab4j</groupId>
128+
<groupId>com.github.gitlab4j.gitlab4j-api</groupId>
129129
<artifactId>gitlab4j-api</artifactId>
130-
<version>7dfec10189</version>
130+
<version>ab6b84c6b0</version>
131131
</dependency>
132132
```
133133

134134
```java
135-
//DEPS https://github.com/gitlab4j/gitlab4j-api/tree/7dfec10189cdcb11e34fc9ead984abcd6316194a
135+
//DEPS https://github.com/gitlab4j/gitlab4j-api/tree/ab6b84c6b096ea3079d25115a59c272a4ae602aa
136136
```
137137

138138
---

Diff for: build.gradle

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
plugins {
22
id 'com.diffplug.spotless' version '6.25.0' apply false
3+
id 'org.kordamp.gradle.jandex' version '2.1.0' apply false
34
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
45
id 'net.researchgate.release' version '3.0.2'
56
}
67

78
wrapper {
8-
gradleVersion = '7.6.2'
9+
gradleVersion = '8.10.1'
910
}
1011

1112
String groupId = 'org.gitlab4j'
@@ -15,6 +16,7 @@ subprojects {
1516
apply plugin: 'signing'
1617
apply plugin: 'com.diffplug.spotless'
1718
apply plugin: 'maven-publish'
19+
apply plugin: 'org.kordamp.gradle.jandex'
1820

1921
group = groupId
2022

@@ -55,6 +57,10 @@ subprojects {
5557
tasks.named('test') {
5658
useJUnitPlatform()
5759
}
60+
61+
tasks.named("javadoc") {
62+
inputs.files(tasks.getByPath("jandex").outputs.files)
63+
}
5864
}
5965

6066
nexusPublishing {

Diff for: gitlab4j-api/src/main/java/org/gitlab4j/api/GitLabApiForm.java

+48-30
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.gitlab4j.api.models.AccessLevel;
1212
import org.gitlab4j.api.models.Variable;
1313
import org.gitlab4j.models.GitLabForm;
14+
import org.gitlab4j.models.GitLabFormValue;
1415
import org.gitlab4j.models.utils.ISO8601;
1516

1617
/**
@@ -35,13 +36,33 @@ public GitLabApiForm(MultivaluedHashMap<String, String> map) {
3536
public GitLabApiForm(int page, int perPage) {
3637
super();
3738
withParam(AbstractApi.PAGE_PARAM, page);
38-
withParam(AbstractApi.PER_PAGE_PARAM, (Integer) perPage);
39+
withParam(AbstractApi.PER_PAGE_PARAM, perPage);
3940
}
4041

4142
public GitLabApiForm(GitLabForm form) {
4243
super();
43-
for (Entry<String, String> e : form.getFormValues().entrySet()) {
44-
this.param(e.getKey(), e.getValue());
44+
for (Entry<String, GitLabFormValue> e : form.getFormValues().entrySet()) {
45+
GitLabFormValue value = e.getValue();
46+
switch (value.getType()) {
47+
case ACCESS_LEVEL:
48+
withParam(e.getKey(), (AccessLevel) value.getValue(), value.isRequired());
49+
break;
50+
case DATE:
51+
withParam(e.getKey(), (Date) value.getValue(), value.isRequired());
52+
break;
53+
case LIST:
54+
withParam(e.getKey(), (List<?>) value.getValue(), value.isRequired());
55+
break;
56+
case MAP:
57+
@SuppressWarnings("unchecked")
58+
Map<String, ?> mapValue = (Map<String, ?>) value.getValue();
59+
withParam(e.getKey(), mapValue, value.isRequired());
60+
break;
61+
case OBJECT:
62+
default:
63+
withParam(e.getKey(), value.getValue(), value.isRequired());
64+
break;
65+
}
4566
}
4667
}
4768

@@ -52,8 +73,8 @@ public GitLabApiForm(GitLabForm form) {
5273
* @param value the value of the field/attribute to add
5374
* @return this GitLabAPiForm instance
5475
*/
55-
public GitLabApiForm withParam(String name, Object value) throws IllegalArgumentException {
56-
return (withParam(name, value, false));
76+
public GitLabApiForm withParam(String name, Object value) {
77+
return withParam(name, value, false);
5778
}
5879

5980
/**
@@ -63,8 +84,8 @@ public GitLabApiForm withParam(String name, Object value) throws IllegalArgument
6384
* @param date the value of the field/attribute to add
6485
* @return this GitLabAPiForm instance
6586
*/
66-
public GitLabApiForm withParam(String name, Date date) throws IllegalArgumentException {
67-
return (withParam(name, date, false));
87+
public GitLabApiForm withParam(String name, Date date) {
88+
return withParam(name, date, false);
6889
}
6990

7091
/**
@@ -76,8 +97,8 @@ public GitLabApiForm withParam(String name, Date date) throws IllegalArgumentExc
7697
* @return this GitLabAPiForm instance
7798
* @throws IllegalArgumentException if a required parameter is null or empty
7899
*/
79-
public GitLabApiForm withParam(String name, Date date, boolean required) throws IllegalArgumentException {
80-
return (withParam(name, (date == null ? null : ISO8601.toString(date)), required));
100+
public GitLabApiForm withParam(String name, Date date, boolean required) {
101+
return withParam(name, date == null ? null : ISO8601.toString(date), required);
81102
}
82103

83104
/**
@@ -87,8 +108,8 @@ public GitLabApiForm withParam(String name, Date date, boolean required) throws
87108
* @param level the value of the field/attribute to add
88109
* @return this GitLabAPiForm instance
89110
*/
90-
public GitLabApiForm withParam(String name, AccessLevel level) throws IllegalArgumentException {
91-
return (withParam(name, level, false));
111+
public GitLabApiForm withParam(String name, AccessLevel level) {
112+
return withParam(name, level, false);
92113
}
93114

94115
/**
@@ -100,49 +121,47 @@ public GitLabApiForm withParam(String name, AccessLevel level) throws IllegalArg
100121
* @return this GitLabAPiForm instance
101122
* @throws IllegalArgumentException if a required parameter is null or empty
102123
*/
103-
public GitLabApiForm withParam(String name, AccessLevel level, boolean required) throws IllegalArgumentException {
104-
return (withParam(name, (level == null ? null : level.toValue()), required));
124+
public GitLabApiForm withParam(String name, AccessLevel level, boolean required) {
125+
return withParam(name, level == null ? null : level.toValue(), required);
105126
}
106127

107128
/**
108129
* Fluent method for adding a List type query and form parameters to a get() or post() call.
109130
*
110-
* @param <T> the type contained by the List
111131
* @param name the name of the field/attribute to add
112132
* @param values a List containing the values of the field/attribute to add
113133
* @return this GitLabAPiForm instance
114134
*/
115-
public <T> GitLabApiForm withParam(String name, List<T> values) {
116-
return (withParam(name, values, false));
135+
public GitLabApiForm withParam(String name, List<?> values) {
136+
return withParam(name, values, false);
117137
}
118138

119139
/**
120140
* Fluent method for adding a List type query and form parameters to a get() or post() call.
121141
*
122-
* @param <T> the type contained by the List
123142
* @param name the name of the field/attribute to add
124143
* @param values a List containing the values of the field/attribute to add
125144
* @param required the field is required flag
126145
* @return this GitLabAPiForm instance
127146
* @throws IllegalArgumentException if a required parameter is null or empty
128147
*/
129-
public <T> GitLabApiForm withParam(String name, List<T> values, boolean required) throws IllegalArgumentException {
148+
public GitLabApiForm withParam(String name, List<?> values, boolean required) {
130149

131150
if (values == null || values.isEmpty()) {
132151
if (required) {
133152
throw new IllegalArgumentException(name + " cannot be empty or null");
134153
}
135154

136-
return (this);
155+
return this;
137156
}
138157

139-
for (T value : values) {
158+
for (Object value : values) {
140159
if (value != null) {
141160
this.param(name + "[]", value.toString());
142161
}
143162
}
144163

145-
return (this);
164+
return this;
146165
}
147166

148167
/**
@@ -154,15 +173,14 @@ public <T> GitLabApiForm withParam(String name, List<T> values, boolean required
154173
* @return this GitLabAPiForm instance
155174
* @throws IllegalArgumentException if a required parameter is null or empty
156175
*/
157-
public GitLabApiForm withParam(String name, Map<String, ?> variables, boolean required)
158-
throws IllegalArgumentException {
176+
public GitLabApiForm withParam(String name, Map<String, ?> variables, boolean required) {
159177

160178
if (variables == null || variables.isEmpty()) {
161179
if (required) {
162180
throw new IllegalArgumentException(name + " cannot be empty or null");
163181
}
164182

165-
return (this);
183+
return this;
166184
}
167185

168186
for (Entry<String, ?> variable : variables.entrySet()) {
@@ -172,7 +190,7 @@ public GitLabApiForm withParam(String name, Map<String, ?> variables, boolean re
172190
}
173191
}
174192

175-
return (this);
193+
return this;
176194
}
177195

178196
/**
@@ -185,14 +203,14 @@ public GitLabApiForm withParam(String name, Map<String, ?> variables, boolean re
185203
* @return this GitLabAPiForm instance
186204
* @throws IllegalArgumentException if a required parameter is null or empty
187205
*/
188-
public GitLabApiForm withParam(String name, Object value, boolean required) throws IllegalArgumentException {
206+
public GitLabApiForm withParam(String name, Object value, boolean required) {
189207

190208
if (value == null) {
191209
if (required) {
192210
throw new IllegalArgumentException(name + " cannot be empty or null");
193211
}
194212

195-
return (this);
213+
return this;
196214
}
197215

198216
String stringValue = value.toString();
@@ -201,7 +219,7 @@ public GitLabApiForm withParam(String name, Object value, boolean required) thro
201219
}
202220

203221
this.param(name.trim(), stringValue);
204-
return (this);
222+
return this;
205223
}
206224

207225
/**
@@ -213,7 +231,7 @@ public GitLabApiForm withParam(String name, Object value, boolean required) thro
213231
public GitLabApiForm withParam(List<Variable> variables) {
214232

215233
if (variables == null || variables.isEmpty()) {
216-
return (this);
234+
return this;
217235
}
218236

219237
variables.forEach(v -> {
@@ -223,6 +241,6 @@ public GitLabApiForm withParam(List<Variable> variables) {
223241
}
224242
});
225243

226-
return (this);
244+
return this;
227245
}
228246
}

0 commit comments

Comments
 (0)