Commit 24b111cf authored by Greg Messner's avatar Greg Messner
Browse files

Changed methods to call Pager method directly.

parent c405df19
...@@ -42,7 +42,7 @@ public class RepositoryApi extends AbstractApi { ...@@ -42,7 +42,7 @@ public class RepositoryApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public List<Branch> getBranches(Object projectIdOrPath) throws GitLabApiException { public List<Branch> getBranches(Object projectIdOrPath) throws GitLabApiException {
return getBranches(projectIdOrPath, null); return getBranches(projectIdOrPath, null, getDefaultPerPage()).all();
} }
/** /**
...@@ -87,7 +87,7 @@ public class RepositoryApi extends AbstractApi { ...@@ -87,7 +87,7 @@ public class RepositoryApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public Stream<Branch> getBranchesStream(Object projectIdOrPath) throws GitLabApiException { public Stream<Branch> getBranchesStream(Object projectIdOrPath) throws GitLabApiException {
return getBranchesStream(projectIdOrPath, null); return getBranches(projectIdOrPath, null, getDefaultPerPage()).stream();
} }
/** /**
...@@ -121,38 +121,38 @@ public class RepositoryApi extends AbstractApi { ...@@ -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.
* *
* <pre><code>GitLab Endpoint: GET /projects/:id/repository/branches?search=:search</code></pre> * <pre><code>GitLab Endpoint: GET /projects/:id/repository/branches?search=:search</code></pre>
* *
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param search the branch name search term * @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 * @throws GitLabApiException if any exception occurs
*/ */
public Stream<Branch> getBranchesStream(Object projectIdOrPath, String search) throws GitLabApiException { public Pager<Branch> getBranches(Object projectIdOrPath, String search, int itemsPerPage) throws GitLabApiException {
return (getBranches(projectIdOrPath, search, getDefaultPerPage()).stream()); MultivaluedMap<String, String> queryParams = ( search == null ? null :
new GitLabApiForm().withParam("search", urlEncode(search)).asMap() );
return (new Pager<Branch>(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.
* *
* <pre><code>GitLab Endpoint: GET /projects/:id/repository/branches?search=:search</code></pre> * <pre><code>GitLab Endpoint: GET /projects/:id/repository/branches?search=:search</code></pre>
* *
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param search the branch name search term * @param search the branch name search term
* @param itemsPerPage the number of Project instances that will be fetched per page * @return the Stream of repository branches for the specified project ID and search term
* @return the list of repository branches for the specified project ID and search term
* *
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public Pager<Branch> getBranches(Object projectIdOrPath, String search, int itemsPerPage) throws GitLabApiException { public Stream<Branch> getBranchesStream(Object projectIdOrPath, String search) throws GitLabApiException {
MultivaluedMap<String, String> queryParams = ( search == null ? null : return (getBranches(projectIdOrPath, search, getDefaultPerPage()).stream());
new GitLabApiForm().withParam("search", urlEncode(search)).asMap() );
return (new Pager<Branch>(this, Branch.class, itemsPerPage, queryParams, "projects",
getProjectIdOrPath(projectIdOrPath), "repository", "branches"));
} }
/** /**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment