-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add two new classes for query options. use reflection to create query…
… objects #528
- Loading branch information
1 parent
0cf4506
commit bc35aa0
Showing
7 changed files
with
201 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
cellbase-core/src/main/java/org/opencb/cellbase/core/api/queries/ProjectionQueryOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2015-2020 OpenCB | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.opencb.cellbase.core.api.queries; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class ProjectionQueryOptions { | ||
|
||
List<String> excludes; | ||
List<String> includes; | ||
|
||
public ProjectionQueryOptions() { | ||
} | ||
|
||
public List<String> getExcludes() { | ||
return excludes; | ||
} | ||
|
||
public ProjectionQueryOptions setExcludes(List<String> excludes) { | ||
this.excludes = excludes; | ||
return this; | ||
} | ||
|
||
public ProjectionQueryOptions addExcludes(String excludes) { | ||
if (this.excludes == null) { | ||
this.excludes = new ArrayList<>(); | ||
} | ||
this.excludes.addAll(Arrays.asList(excludes.split(","))); | ||
return this; | ||
} | ||
|
||
public List<String> getIncludes() { | ||
return includes; | ||
} | ||
|
||
public ProjectionQueryOptions setIncludes(List<String> includes) { | ||
this.includes = includes; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ProjectionQueryOptions{" + | ||
"excludes=" + excludes + | ||
", includes=" + includes + | ||
'}'; | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
cellbase-core/src/main/java/org/opencb/cellbase/core/api/queries/QueryOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright 2015-2020 OpenCB | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.opencb.cellbase.core.api.queries; | ||
|
||
public class QueryOptions extends ProjectionQueryOptions { | ||
|
||
protected Integer skip; | ||
protected Integer limit; | ||
protected String sort; | ||
protected Boolean count; | ||
protected Order order; | ||
|
||
enum Order { | ||
ASCENDING, | ||
DESCENDING | ||
} | ||
|
||
public QueryOptions() { | ||
} | ||
|
||
public Integer getSkip() { | ||
return skip; | ||
} | ||
|
||
public QueryOptions setSkip(Integer skip) { | ||
this.skip = skip; | ||
return this; | ||
} | ||
|
||
public Integer getLimit() { | ||
return limit; | ||
} | ||
|
||
public QueryOptions setLimit(Integer limit) { | ||
this.limit = limit; | ||
return this; | ||
} | ||
|
||
public String getSort() { | ||
return sort; | ||
} | ||
|
||
public QueryOptions setSort(String sort) { | ||
this.sort = sort; | ||
return this; | ||
} | ||
|
||
public Boolean getCount() { | ||
return count; | ||
} | ||
|
||
public QueryOptions setCount(Boolean count) { | ||
this.count = count; | ||
return this; | ||
} | ||
|
||
public Order getOrder() { | ||
return order; | ||
} | ||
|
||
public QueryOptions setOrder(Order order) { | ||
this.order = order; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "QueryOptions{" + | ||
"skip=" + skip + | ||
", limit=" + limit + | ||
", sort='" + sort + '\'' + | ||
", count=" + count + | ||
", order=" + order + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.