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