Skip to content

Commit be5072a

Browse files
committed
Added getXxxxxStream() methods that return Java 8 Streams.
1 parent b38252f commit be5072a

File tree

9 files changed

+514
-351
lines changed

9 files changed

+514
-351
lines changed

src/main/java/org/gitlab4j/api/EpicsApi.java

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.Date;
44
import java.util.List;
55
import java.util.Optional;
6+
import java.util.stream.Stream;
67

78
import javax.ws.rs.core.Form;
89
import javax.ws.rs.core.GenericType;
@@ -29,15 +30,15 @@ public EpicsApi(GitLabApi gitLabApi) {
2930

3031
/**
3132
* Gets all epics of the requested group and its subgroups.
32-
*
33+
*
3334
* <pre><code>GitLab Endpoint: GET /groups/:id/epics</code></pre>
3435
*
3536
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
3637
* @return a list of all epics of the requested group and its subgroups
3738
* @throws GitLabApiException if any exception occurs
3839
*/
3940
public List<Epic> getEpics(Object groupIdOrPath) throws GitLabApiException {
40-
return (getEpics(groupIdOrPath, 1, getDefaultPerPage()));
41+
return (getEpics(groupIdOrPath, getDefaultPerPage()).all());
4142
}
4243

4344
/**
@@ -70,6 +71,19 @@ public Pager<Epic> getEpics(Object groupIdOrPath, int itemsPerPage) throws GitLa
7071
return (new Pager<Epic>(this, Epic.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "epics"));
7172
}
7273

74+
/**
75+
* Gets all epics of the requested group and its subgroups as a Stream.
76+
*
77+
* <pre><code>GitLab Endpoint: GET /groups/:id/epics</code></pre>
78+
*
79+
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
80+
* @return a Stream of all epics of the requested group and its subgroups
81+
* @throws GitLabApiException if any exception occurs
82+
*/
83+
public Stream<Epic> getEpicsStream(Object groupIdOrPath) throws GitLabApiException {
84+
return (getEpics(groupIdOrPath, getDefaultPerPage()).stream());
85+
}
86+
7387
/**
7488
* Gets all epics of the requested group and its subgroups.
7589
*
@@ -87,7 +101,7 @@ public Pager<Epic> getEpics(Object groupIdOrPath, int itemsPerPage) throws GitLa
87101
*/
88102
public List<Epic> getEpics(Object groupIdOrPath, Integer authorId, String labels, EpicOrderBy orderBy,
89103
SortOrder sortOrder, String search) throws GitLabApiException {
90-
return (getEpics(groupIdOrPath, authorId, labels, orderBy, sortOrder, search, 1, getDefaultPerPage()));
104+
return (getEpics(groupIdOrPath, authorId, labels, orderBy, sortOrder, search, getDefaultPerPage()).all());
91105
}
92106

93107
/**
@@ -146,6 +160,26 @@ public Pager<Epic> getEpics(Object groupIdOrPath, Integer authorId, String label
146160
return (new Pager<Epic>(this, Epic.class, itemsPerPage, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "epics"));
147161
}
148162

163+
/**
164+
* Gets all epics of the requested group and its subgroups as a Stream.
165+
*
166+
* <pre><code>GitLab Endpoint: GET /groups/:id/epics</code></pre>
167+
*
168+
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
169+
* @param authorId returns epics created by the given user id
170+
* @param labels return epics matching a comma separated list of labels names.
171+
* Label names from the epic group or a parent group can be used
172+
* @param orderBy return epics ordered by CREATED_AT or UPDATED_AT. Default is CREATED_AT
173+
* @param sortOrder return epics sorted in ASC or DESC order. Default is DESC
174+
* @param search search epics against their title and description
175+
* @return a Stream of matching epics of the requested group and its subgroups
176+
* @throws GitLabApiException if any exception occurs
177+
*/
178+
public Stream<Epic> getEpicsStream(Object groupIdOrPath, Integer authorId, String labels, EpicOrderBy orderBy,
179+
SortOrder sortOrder, String search) throws GitLabApiException {
180+
return (getEpics(groupIdOrPath, authorId, labels, orderBy, sortOrder, search, getDefaultPerPage()).stream());
181+
}
182+
149183
/**
150184
* Get a single epic for the specified group.
151185
*
@@ -305,11 +339,10 @@ public Epic updateEpic(Object groupIdOrPath, Integer epicIid, Epic epic) throws
305339
public void deleteEpic(Object groupIdOrPath, Integer epicIid) throws GitLabApiException {
306340
delete(Response.Status.NO_CONTENT, null, "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid);
307341
}
308-
309342

310343
/**
311344
* Gets all issues that are assigned to an epic and the authenticated user has access to.
312-
*
345+
*
313346
* <pre><code>GitLab Endpoint: GET /groups/:id/epics/:epic_iid/issues</code></pre>
314347
*
315348
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
@@ -318,13 +351,13 @@ public void deleteEpic(Object groupIdOrPath, Integer epicIid) throws GitLabApiEx
318351
* @throws GitLabApiException if any exception occurs
319352
*/
320353
public List<Epic> getEpicIssues(Object groupIdOrPath, Integer epicIid) throws GitLabApiException {
321-
return (getEpicIssues(groupIdOrPath, epicIid, 1, getDefaultPerPage()));
354+
return (getEpicIssues(groupIdOrPath, epicIid, getDefaultPerPage()).all());
322355
}
323356

324357
/**
325358
* Gets all issues that are assigned to an epic and the authenticated user has access to
326359
* using the specified page and per page setting.
327-
*
360+
*
328361
* <pre><code>GitLab Endpoint: GET /groups/:id/epics/:epic_iid/issues</code></pre>
329362
*
330363
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
@@ -341,7 +374,7 @@ public List<Epic> getEpicIssues(Object groupIdOrPath, Integer epicIid, int page,
341374

342375
/**
343376
* Get a Pager of all issues that are assigned to an epic and the authenticated user has access to.
344-
*
377+
*
345378
* <pre><code>GitLab Endpoint: GET /groups/:id/epics/:epic_iid/issues</code></pre>
346379
*
347380
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
@@ -354,6 +387,20 @@ public Pager<Epic> getEpicIssues(Object groupIdOrPath, Integer epicIid, int item
354387
return (new Pager<Epic>(this, Epic.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "issues"));
355388
}
356389

390+
/**
391+
* Gets all issues that are assigned to an epic and the authenticated user has access to as a Stream.
392+
*
393+
* <pre><code>GitLab Endpoint: GET /groups/:id/epics/:epic_iid/issues</code></pre>
394+
*
395+
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
396+
* @param epicIid the IID of the epic to get issues for
397+
* @return a Stream of all epic issues belonging to the specified epic
398+
* @throws GitLabApiException if any exception occurs
399+
*/
400+
public Stream<Epic> getEpicIssuesStream(Object groupIdOrPath, Integer epicIid) throws GitLabApiException {
401+
return (getEpicIssues(groupIdOrPath, epicIid, getDefaultPerPage()).stream());
402+
}
403+
357404
/**
358405
* Creates an epic - issue association. If the issue in question belongs to another epic
359406
* it is unassigned from that epic.

src/main/java/org/gitlab4j/api/MarkdownApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public MarkdownApi(GitLabApi gitLabApi) {
1717
/**
1818
* Render an arbitrary Markdown document.
1919
*
20-
* POST /api/v4/markdown
20+
* <pre><code>GitLab Endpoint: POST /api/v4/markdown</code></pre>
2121
*
2222
* @param text text to be transformed
2323
* @return a Markdown instance with transformed info
@@ -26,7 +26,7 @@ public MarkdownApi(GitLabApi gitLabApi) {
2626
*/
2727
public Markdown getMarkdown(String text) throws GitLabApiException {
2828

29-
if(!isApiVersion(ApiVersion.V4)){
29+
if (!isApiVersion(ApiVersion.V4)) {
3030
throw new GitLabApiException("Api version must be v4");
3131
}
3232

0 commit comments

Comments
 (0)