QueryProjects: Make setter methods chainable
Change-Id: I8544af6114d554b39d11358971fed77c1b0b8f6b
This commit is contained in:
@@ -153,12 +153,12 @@ class ProjectsImpl implements Projects {
|
||||
|
||||
private List<ProjectInfo> query(QueryRequest r) throws RestApiException {
|
||||
try {
|
||||
QueryProjects myQueryProjects = queryProvider.get();
|
||||
myQueryProjects.setQuery(r.getQuery());
|
||||
myQueryProjects.setLimit(r.getLimit());
|
||||
myQueryProjects.setStart(r.getStart());
|
||||
|
||||
return myQueryProjects.apply(TopLevelResource.INSTANCE);
|
||||
return queryProvider
|
||||
.get()
|
||||
.withQuery(r.getQuery())
|
||||
.withLimit(r.getLimit())
|
||||
.withStart(r.getStart())
|
||||
.apply(TopLevelResource.INSTANCE);
|
||||
} catch (OrmException e) {
|
||||
throw new RestApiException("Cannot query projects", e);
|
||||
}
|
||||
|
||||
@@ -49,8 +49,9 @@ public class QueryProjects implements RestReadView<TopLevelResource> {
|
||||
name = "--query",
|
||||
aliases = {"-q"},
|
||||
usage = "project query")
|
||||
public void setQuery(String query) {
|
||||
public QueryProjects withQuery(String query) {
|
||||
this.query = query;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Option(
|
||||
@@ -58,8 +59,9 @@ public class QueryProjects implements RestReadView<TopLevelResource> {
|
||||
aliases = {"-n"},
|
||||
metaVar = "CNT",
|
||||
usage = "maximum number of projects to list")
|
||||
public void setLimit(int limit) {
|
||||
public QueryProjects withLimit(int limit) {
|
||||
this.limit = limit;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Option(
|
||||
@@ -67,8 +69,9 @@ public class QueryProjects implements RestReadView<TopLevelResource> {
|
||||
aliases = {"-S"},
|
||||
metaVar = "CNT",
|
||||
usage = "number of projects to skip")
|
||||
public void setStart(int start) {
|
||||
public QueryProjects withStart(int start) {
|
||||
this.start = start;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Inject
|
||||
|
||||
Reference in New Issue
Block a user