Class Expression
- java.lang.Object
-
- com.feedzai.commons.sql.abstraction.dml.Expression
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AlterColumn,Between,Case,Cast,Coalesce,Concat,Delete,DropPrimaryKey,Function,Join,K,Literal,Modulo,Name,Query,Rename,RepeatDelimiter,StringAgg,Truncate,Union,Update,Values,Values.Row,View,When,With
public abstract class Expression extends Object implements Serializable
A generic SQL Expression capable of being translated.- Since:
- 2.0.0
- Author:
- Rui Vilao (rui.vilao@feedzai.com)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected StringaliasThe expression alias if applicable.protected booleanenclosedTrue if the expression is to be enclosed in parenthesis.protected List<Join>joinsThe list of joins, if applicable.protected StringorderingThe string that specified the ordering if applicable.protected PdbPropertiespropertiesThe PDB properties.protected booleanquotesTrue if the expression is to be put around quotes.protected AbstractTranslatortranslatorThe abstract translator.protected booleanwithNoLockThe SQL Server's no lock keyword.
-
Constructor Summary
Constructors Constructor Description Expression()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Expressionalias(String alias)Aliases this expression.Expressionasc()Sets ordering to ascendant.Expressiondesc()Sets ordering to descendant.Expressionenclose()Encloses this expression with parenthesis.ExpressionfullOuterJoin(Expression table, Expression expr)Sets a full outer join with the current table.StringgetAlias()Gets the alias.List<Join>getJoins()Gets the join list.StringgetOrdering()Gets the ordering.ExpressioninnerJoin(Expression table, Expression expr)Sets an inner join with the current table.booleanisAliased()Checks if this expression is to be aliased.booleanisEnclosed()Checks if this expression is to be enclosed in parenthesis.booleanisQuote()Checks if this expression is to be quoted.booleanisQuotes()Checks if this expression is to be translated with quotes.booleanisWithNoLock()Checks if this expression (TABLES) is with no lock.ExpressionleftOuterJoin(Expression table, Expression expr)Sets a left outer join with the current table.ExpressionrightOuterJoin(Expression table, Expression expr)Sets a right outer join with the current table.abstract Stringtranslate()Translates the expression.Expressionunquote()Removes the quotes for this expression.ExpressionwithNoLock()Sets no lock keyword on SQL Server tables.
-
-
-
Field Detail
-
translator
@Inject protected AbstractTranslator translator
The abstract translator.
-
properties
@Inject protected PdbProperties properties
The PDB properties.
-
alias
protected String alias
The expression alias if applicable.
-
enclosed
protected boolean enclosed
True if the expression is to be enclosed in parenthesis.
-
quotes
protected boolean quotes
True if the expression is to be put around quotes.
-
ordering
protected String ordering
The string that specified the ordering if applicable.
-
withNoLock
protected boolean withNoLock
The SQL Server's no lock keyword.
-
-
Method Detail
-
translate
public abstract String translate()
Translates the expression.- Returns:
- A translation of the implementing expression.
-
alias
public Expression alias(String alias)
Aliases this expression.- Parameters:
alias- The alias.- Returns:
- This expression.
-
unquote
public Expression unquote()
Removes the quotes for this expression.- Returns:
- This expression.
-
enclose
public Expression enclose()
Encloses this expression with parenthesis.- Returns:
- This expression.
-
asc
public Expression asc()
Sets ordering to ascendant.- Returns:
- This expression.
-
desc
public Expression desc()
Sets ordering to descendant.- Returns:
- This expression.
-
isEnclosed
public boolean isEnclosed()
Checks if this expression is to be enclosed in parenthesis.- Returns:
trueif this expression is enclosed,falseotherwise.
-
isQuote
public boolean isQuote()
Checks if this expression is to be quoted.- Returns:
trueif this expression is quoted,falseotherwise.
-
isAliased
public boolean isAliased()
Checks if this expression is to be aliased.- Returns:
trueif this expression is aliased,falseotherwise.
-
innerJoin
public Expression innerJoin(Expression table, Expression expr)
Sets an inner join with the current table.- Parameters:
table- The table to join.expr- The expressions to join.- Returns:
- This expression.
-
leftOuterJoin
public Expression leftOuterJoin(Expression table, Expression expr)
Sets a left outer join with the current table.- Parameters:
table- The table to join.expr- The expressions to join.- Returns:
- This expression.
-
rightOuterJoin
public Expression rightOuterJoin(Expression table, Expression expr)
Sets a right outer join with the current table.- Parameters:
table- The table to join.expr- The expressions to join.- Returns:
- This expression.
-
fullOuterJoin
public Expression fullOuterJoin(Expression table, Expression expr)
Sets a full outer join with the current table.- Parameters:
table- The table to join.expr- The expressions to join.- Returns:
- This expression.
-
withNoLock
public Expression withNoLock()
Sets no lock keyword on SQL Server tables.- Returns:
- This expression.
-
isWithNoLock
public boolean isWithNoLock()
Checks if this expression (TABLES) is with no lock.- Returns:
trueif this expression (TABLE) is with no lock,falseotherwise.
-
getOrdering
public String getOrdering()
Gets the ordering.- Returns:
- The ordering.
-
isQuotes
public boolean isQuotes()
Checks if this expression is to be translated with quotes.- Returns:
trueif this expression is to be translated with quotes,falseotherwise.
-
getAlias
public String getAlias()
Gets the alias.- Returns:
- The alias,
nullif not applicable.
-
-