-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support comparing to another fields (#46)
- Loading branch information
Showing
15 changed files
with
488 additions
and
135 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
64 changes: 64 additions & 0 deletions
64
src/main/java/com/yahoo/bullet/parsing/ObjectFilterClause.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 2018, Oath Inc. | ||
* Licensed under the terms of the Apache License, Version 2.0. | ||
* See the LICENSE file associated with the project for terms. | ||
*/ | ||
package com.yahoo.bullet.parsing; | ||
|
||
import com.google.gson.annotations.Expose; | ||
import com.google.gson.annotations.SerializedName; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class ObjectFilterClause extends FilterClause<ObjectFilterClause.Value> { | ||
@Getter @AllArgsConstructor | ||
public static class Value { | ||
public enum Kind { | ||
@SerializedName("VALUE") | ||
VALUE, | ||
@SerializedName("FIELD") | ||
FIELD, | ||
@SerializedName("CAST") | ||
CAST | ||
} | ||
@Expose | ||
private Kind kind; | ||
@Expose | ||
private String value; | ||
|
||
@Override | ||
public String toString() { | ||
return "{kind: " + kind + ", " + "value: " + value + "}"; | ||
} | ||
} | ||
|
||
/** | ||
* Default Constructor. GSON recommended. | ||
*/ | ||
public ObjectFilterClause() { | ||
super(); | ||
} | ||
|
||
/** | ||
* Constructor takes a {@link StringFilterClause} object to construct from. | ||
* | ||
* @param stringFilterClause The {@link StringFilterClause} object tor construct from. | ||
*/ | ||
public ObjectFilterClause(StringFilterClause stringFilterClause) { | ||
this.operation = stringFilterClause.operation; | ||
this.field = stringFilterClause.field; | ||
this.patterns = stringFilterClause.patterns; | ||
List<String> stringValues = stringFilterClause.getValues(); | ||
if (stringValues != null) { | ||
values = stringValues.stream().map(s -> s == null ? null : new Value(Value.Kind.VALUE, s)).collect(Collectors.toList()); | ||
} | ||
} | ||
|
||
@Override | ||
public String getValue(Value value) { | ||
return value.getValue(); | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/main/java/com/yahoo/bullet/parsing/StringFilterClause.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,20 @@ | ||
/* | ||
* Copyright 2018, Oath Inc. | ||
* Licensed under the terms of the Apache License, Version 2.0. | ||
* See the LICENSE file associated with the project for terms. | ||
*/ | ||
package com.yahoo.bullet.parsing; | ||
|
||
public class StringFilterClause extends FilterClause<String> { | ||
/** | ||
* Default Constructor. GSON recommended. | ||
*/ | ||
public StringFilterClause() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public String getValue(String value) { | ||
return value; | ||
} | ||
} |
Oops, something went wrong.