This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Massive refactoring of modules handling SQL functions to allow for ne…
…sting
- Loading branch information
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
...c/main/java/com/amazon/opendistroforelasticsearch/sql/legacy/utils/SQLDefinitionExpr.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,73 @@ | ||
package com.amazon.opendistroforelasticsearch.sql.legacy.utils; | ||
|
||
import com.alibaba.druid.sql.ast.SQLExprImpl; | ||
import com.alibaba.druid.sql.ast.expr.SQLValuableExpr; | ||
import com.alibaba.druid.sql.visitor.SQLASTVisitor; | ||
|
||
public class SQLDefinitionExpr extends SQLExprImpl implements SQLValuableExpr { | ||
|
||
private final String name; | ||
|
||
private final String definition; | ||
|
||
public SQLDefinitionExpr(String name, String definition) { | ||
this.name = name; | ||
this.definition = definition; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getDefinition() { | ||
return definition; | ||
} | ||
|
||
@Override | ||
public Object getValue() { | ||
return this.getName(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
SQLDefinitionExpr other = (SQLDefinitionExpr) obj; | ||
if (name == null) { | ||
if (other.name != null) { | ||
return false; | ||
} | ||
} else if (!name.equals(other.name)) { | ||
return false; | ||
} | ||
if (definition == null) { | ||
if (other.definition != null) { | ||
return false; | ||
} | ||
} else if (!definition.equals(other.definition)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((name == null) ? 0 : name.hashCode()); | ||
result = prime * result + ((definition == null) ? 0 : definition.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
protected void accept0(SQLASTVisitor visitor) { | ||
|
||
} | ||
} |