From 24b111cf66769cbd83e3c1d4923541f573dc8b26 Mon Sep 17 00:00:00 2001 From: Greg Messner Date: Fri, 28 Feb 2020 23:12:53 -0800 Subject: [PATCH] Changed methods to call Pager method directly. --- .../java/org/gitlab4j/api/RepositoryApi.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/gitlab4j/api/RepositoryApi.java b/src/main/java/org/gitlab4j/api/RepositoryApi.java index 80c163da..392ea045 100644 --- a/src/main/java/org/gitlab4j/api/RepositoryApi.java +++ b/src/main/java/org/gitlab4j/api/RepositoryApi.java @@ -42,7 +42,7 @@ public class RepositoryApi extends AbstractApi { * @throws GitLabApiException if any exception occurs */ public List getBranches(Object projectIdOrPath) throws GitLabApiException { - return getBranches(projectIdOrPath, null); + return getBranches(projectIdOrPath, null, getDefaultPerPage()).all(); } /** @@ -87,7 +87,7 @@ public class RepositoryApi extends AbstractApi { * @throws GitLabApiException if any exception occurs */ public Stream getBranchesStream(Object projectIdOrPath) throws GitLabApiException { - return getBranchesStream(projectIdOrPath, null); + return getBranches(projectIdOrPath, null, getDefaultPerPage()).stream(); } /** @@ -121,38 +121,38 @@ public class RepositoryApi extends AbstractApi { } /** - * Get a Stream of repository branches from a project, sorted by name alphabetically, filter by the search term. + * Get a Pager of repository branches from a project, sorted by name alphabetically, filter by the search term. * *
GitLab Endpoint: GET /projects/:id/repository/branches?search=:search
* * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param search the branch name search term - * @return the Stream of repository branches for the specified project ID and search term + * @param itemsPerPage the number of Project instances that will be fetched per page + * @return the list of repository branches for the specified project ID and search term * * @throws GitLabApiException if any exception occurs */ - public Stream getBranchesStream(Object projectIdOrPath, String search) throws GitLabApiException { - return (getBranches(projectIdOrPath, search, getDefaultPerPage()).stream()); + public Pager getBranches(Object projectIdOrPath, String search, int itemsPerPage) throws GitLabApiException { + MultivaluedMap queryParams = ( search == null ? null : + new GitLabApiForm().withParam("search", urlEncode(search)).asMap() ); + + return (new Pager(this, Branch.class, itemsPerPage, queryParams, "projects", + getProjectIdOrPath(projectIdOrPath), "repository", "branches")); } /** - * Get a Pager of repository branches from a project, sorted by name alphabetically, filter by the search term. + * Get a Stream of repository branches from a project, sorted by name alphabetically, filter by the search term. * *
GitLab Endpoint: GET /projects/:id/repository/branches?search=:search
* * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param search the branch name search term - * @param itemsPerPage the number of Project instances that will be fetched per page - * @return the list of repository branches for the specified project ID and search term + * @return the Stream of repository branches for the specified project ID and search term * * @throws GitLabApiException if any exception occurs */ - public Pager getBranches(Object projectIdOrPath, String search, int itemsPerPage) throws GitLabApiException { - MultivaluedMap queryParams = ( search == null ? null : - new GitLabApiForm().withParam("search", urlEncode(search)).asMap() ); - - return (new Pager(this, Branch.class, itemsPerPage, queryParams, "projects", - getProjectIdOrPath(projectIdOrPath), "repository", "branches")); + public Stream getBranchesStream(Object projectIdOrPath, String search) throws GitLabApiException { + return (getBranches(projectIdOrPath, search, getDefaultPerPage()).stream()); } /** -- GitLab