-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to support $eq comparison operator. (#55)
- Loading branch information
1 parent
7039dad
commit 61164e7
Showing
8 changed files
with
179 additions
and
19 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
45 changes: 38 additions & 7 deletions
45
...ava/io/stargate/sgv3/docsapi/api/model/command/clause/filter/ValueComparisonOperator.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 |
---|---|---|
@@ -1,11 +1,42 @@ | ||
package io.stargate.sgv3.docsapi.api.model.command.clause.filter; | ||
|
||
/** List of value operator that can be used in Filter clause */ | ||
import io.stargate.sgv3.docsapi.exception.DocsException; | ||
import io.stargate.sgv3.docsapi.exception.ErrorCode; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* List of value operator that can be used in Filter clause Have commented the unsupported | ||
* operators, will add it as we support them | ||
*/ | ||
public enum ValueComparisonOperator implements FilterOperator { | ||
EQ, | ||
GT, | ||
GTE, | ||
LT, | ||
LTE, | ||
NE | ||
EQ("$eq"); | ||
/*GT("$gt"), | ||
GTE("$gte"), | ||
LT("$lt"), | ||
LTE("$lte"), | ||
NE("$ne");*/ | ||
|
||
private String operator; | ||
|
||
ValueComparisonOperator(String operator) { | ||
this.operator = operator; | ||
} | ||
|
||
private static final Map<String, ValueComparisonOperator> operatorMap = new HashMap<>(); | ||
|
||
static { | ||
for (ValueComparisonOperator filterOperator : ValueComparisonOperator.values()) { | ||
operatorMap.put(filterOperator.operator, filterOperator); | ||
} | ||
} | ||
|
||
public static ValueComparisonOperator getComparisonOperator(String operator) { | ||
final ValueComparisonOperator valueComparisonOperator = operatorMap.get(operator); | ||
if (valueComparisonOperator == null) | ||
throw new DocsException( | ||
ErrorCode.UNSUPPORTED_FILTER_OPERATION, "Unsupported filter operation " + operator); | ||
|
||
return valueComparisonOperator; | ||
} | ||
} |
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
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