Class AbstractScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.tools.model.AbstractStateObjectBuilder
-
- org.eclipse.persistence.jpa.jpql.tools.model.AbstractScalarExpressionStateObjectBuilder<T>
-
- All Implemented Interfaces:
IScalarExpressionStateObjectBuilder<T>
- Direct Known Subclasses:
AbstractConditionalExpressionStateObjectBuilder,AbstractNewValueStateObjectBuilder,AbstractSelectExpressionStateObjectBuilder,AbstractSimpleSelectExpressionStateObjectBuilder
public abstract class AbstractScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>> extends AbstractStateObjectBuilder implements IScalarExpressionStateObjectBuilder<T>
This abstract definition of a builder provides the support for creating expressions defined by ascalar expression.- Since:
- 2.4
- Version:
- 2.4
- Author:
- Pascal Filion
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractScalarExpressionStateObjectBuilder(StateObject parent)Creates a newAbstractScalarExpressionStateObjectBuilder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tabs(T builder)Creates the expressionABS(x).Tadd(T builder)Creates the expressionx + y.protected voidarithmetic(boolean plusSign)protected voidavg(boolean distinct, String path)Tavg(String path)Creates the expressionAVG(path).TavgDistinct(String path)Creates the expressionAVG(DISTINCT path).protected StateObjectbuildCollectionPath(String path)protected StateObjectbuildIdentificationVariable(String literal)protected StateObjectbuildInputParameter(String parameter)protected StateObjectbuildNumeric(Number number)protected StateObjectbuildNumeric(String number)protected StateObjectbuildStateFieldPath(String path)protected StateObjectbuildStringLiteral(String literal)Tcase_(ICaseExpressionStateObjectBuilder builder)Creates a newCASEexpression.Tcoalesce(T builder1, T builder2, T... builders)Create the expressionCOALESCE(scalar_expression {, scalar_expression}+).Tconcat(T builder1, T builder2, T... builders)Creates the expressionCONCAT(string_primary, string_primary {, string_primary}*).protected voidcount(boolean distinct, String path)Tcount(String path)Creates the expressionCOUNT(identification_variable | state_field_path_expression | single_valued_object_path_expression).TcountDistinct(String path)Creates the expressionCOUNT(DISTINCT identification_variable | state_field_path_expression | single_valued_object_path_expression).TcurrentDate()Creates the expression representingCURRENT_DATE.TcurrentTime()Creates the expression representingCURRENT_TIME.TcurrentTimestamp()Creates the expression representingCURRENT_TIMESTAMP.Tdate(String jdbcDate)Creates a new date using the JDBC syntax of a date.Tdivide(T builder)Creates the expressionx / y.TentityType(String entityTypeName)Creates a new entity type literal.TenumLiteral(Enum<? extends Enum<?>> enumConstant)Creates a new enum literal.Tfunction(String identifier, String functionName, String... arguments)Creates the expression<identifier>('functionName' {, expression}*).Tfunction(String identifier, String functionName, T... arguments)Creates the expression<identifier>('functionName' {, expression}*).ICaseExpressionStateObjectBuildergetCaseBuilder()Returns the builder that can create aCASEexpression, which requires aIConditionalExpressionStateObjectBuilderto build theWHENclauses.protected StateObjectgetParent()Returns the parent of the expression to build, which is only required when a JPQL fragment needs to be parsed.Tindex(String variable)Creates the expressionINDEX(identification_variable).Tlength(T builder)Creates the expressionLENGTH(expression).protected StateObjectliteral(String literal)protected List<StateObject>literals(String... literals)Tlocate(T parameter1, T parameter2)Creates the expressionLOCATE(string_primary, string_primary).Tlocate(T parameter1, T parameter2, T parameter3)Creates the expressionLOCATE(string_primary, string_primary [, simple_arithmetic_expression]).protected voidmax(boolean distinct, String path)Tmax(String path)Creates the expressionMAX(path).TmaxDistinct(String path)Creates the expressionMAX(DISTINCT path).protected voidmin(boolean distinct, String path)Tmin(String path)Creates the expressionAVG(path).TminDistinct(String path)Creates the expressionAVG(DISTINCT path).Tminus(T builder)Creates the expression- x.Tmod(T parameter1, T parameter2)Creates the expressionMOD(simple_arithmetic_expression, simple_arithmetic_expression).Tmultiply(T builder)Creates the expressionx * y.TnullIf(T builder1, T builder2)Create the expressionNULLIF(scalar_expression, scalar_expression).Tnumeric(Number number)Creates the numeric literal.Tnumeric(String number)Creates the numeric literal.Tparameter(String parameter)Creates the input parameter.Tpath(String path)Creates a new state field path expression.Tplus(T builder)Creates the expression+ x.Tsize(String path)Creates the expressionSIZE(collection_valued_path_expression).Tsqrt(T builder)Creates the expressionSQRT(x).protected List<StateObject>stateObjects(int count)Returns a list of theStateObjectsthat were previously created.protected List<StateObject>stateObjects(T... builders)Returns a list of theStateObjectsthat were previously created.Tstring(String literal)Creates a new string literal.Tsub(T builder)Creates an encapsulated expression:(expression).Tsubtract(T builder)Creates the expressionx - y.protected voidsum(boolean distinct, String path)Tsum(String path)Creates the expressionSUM(path).TsumDistinct(String path)Creates the expressionSUM(path).Ttype(String path)Creates the expressionTYPE(identification_variable | single_valued_object_path_expression | input_parameter).-
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.AbstractStateObjectBuilder
add, checkBuilder, checkBuilders, hasStateObjects, pop
-
-
-
-
Constructor Detail
-
AbstractScalarExpressionStateObjectBuilder
protected AbstractScalarExpressionStateObjectBuilder(StateObject parent)
Creates a newAbstractScalarExpressionStateObjectBuilder.- Parameters:
parent- The parent of the expression to build, which is only required when a JPQL fragment needs to be parsed
-
-
Method Detail
-
abs
public T abs(T builder)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionABS(x).- Specified by:
absin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
builder- The parameter of theABSexpression- Returns:
- This This builder
-
add
public T add(T builder)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionx + y.- Specified by:
addin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
builder- The right side of the addition expression- Returns:
- This builder
-
arithmetic
protected void arithmetic(boolean plusSign)
-
avg
protected void avg(boolean distinct, String path)
-
avg
public T avg(String path)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionAVG(path).- Specified by:
avgin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
path- The state field path expression- Returns:
- This This builder
-
avgDistinct
public T avgDistinct(String path)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionAVG(DISTINCT path).- Specified by:
avgDistinctin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
path- The state field path expression- Returns:
- This This builder
-
buildCollectionPath
protected StateObject buildCollectionPath(String path)
-
buildIdentificationVariable
protected StateObject buildIdentificationVariable(String literal)
-
buildInputParameter
protected StateObject buildInputParameter(String parameter)
-
buildNumeric
protected StateObject buildNumeric(Number number)
-
buildNumeric
protected StateObject buildNumeric(String number)
-
buildStateFieldPath
protected StateObject buildStateFieldPath(String path)
-
buildStringLiteral
protected StateObject buildStringLiteral(String literal)
-
case_
public T case_(ICaseExpressionStateObjectBuilder builder)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates a newCASEexpression.- Specified by:
case_in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
builder- Thebuilderof aCASEexpression- Returns:
- This This builder
-
coalesce
public T coalesce(T builder1, T builder2, T... builders)
Description copied from interface:IScalarExpressionStateObjectBuilderCreate the expressionCOALESCE(scalar_expression {, scalar_expression}+).- Specified by:
coalescein interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
builder1- The first scalar expressionbuilder2- The second scalar expressionbuilders- The subsequent scalar expressions- Returns:
- This This builder
-
concat
public T concat(T builder1, T builder2, T... builders)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionCONCAT(string_primary, string_primary {, string_primary}*).- Specified by:
concatin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
builder1- The first argument of the expressionbuilder2- The second argument of the expressionbuilders- The subsequence arguments of the expression, which are optional- Returns:
- This This builder
-
count
protected void count(boolean distinct, String path)
-
count
public T count(String path)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionCOUNT(identification_variable | state_field_path_expression | single_valued_object_path_expression).- Specified by:
countin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
path- The state field path expression- Returns:
- This This builder
-
countDistinct
public T countDistinct(String path)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionCOUNT(DISTINCT identification_variable | state_field_path_expression | single_valued_object_path_expression).- Specified by:
countDistinctin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
path- The state field path expression- Returns:
- This This builder
-
currentDate
public T currentDate()
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expression representingCURRENT_DATE.- Specified by:
currentDatein interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Returns:
- This This builder
-
currentTime
public T currentTime()
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expression representingCURRENT_TIME.- Specified by:
currentTimein interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Returns:
- This This builder
-
currentTimestamp
public T currentTimestamp()
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expression representingCURRENT_TIMESTAMP.- Specified by:
currentTimestampin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Returns:
- This This builder
-
date
public T date(String jdbcDate)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates a new date using the JDBC syntax of a date.- Specified by:
datein interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Returns:
- This This builder
-
divide
public T divide(T builder)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionx / y.- Specified by:
dividein interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
builder- The right side of the division expression- Returns:
- This This builder
-
entityType
public T entityType(String entityTypeName)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates a new entity type literal.- Specified by:
entityTypein interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
entityTypeName- The short name of the entity- Returns:
- This This builder
-
enumLiteral
public T enumLiteral(Enum<? extends Enum<?>> enumConstant)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates a new enum literal.- Specified by:
enumLiteralin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
enumConstant- The enum constant- Returns:
- This This builder
-
function
public T function(String identifier, String functionName, String... arguments)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expression<identifier>('functionName' {, expression}*).- Specified by:
functionin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
identifier- The JPQL identifier that is used to identify the SQL expressionfunctionName- The name of the native SQL functionarguments- The arguments of the expression- Returns:
- This builder
-
function
public T function(String identifier, String functionName, T... arguments)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expression<identifier>('functionName' {, expression}*).- Specified by:
functionin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
identifier- The JPQL identifier that is used to identify the SQL expressionfunctionName- The name of the native SQL functionarguments- The arguments of the expression- Returns:
- This builder
-
getCaseBuilder
public ICaseExpressionStateObjectBuilder getCaseBuilder()
Description copied from interface:IScalarExpressionStateObjectBuilderReturns the builder that can create aCASEexpression, which requires aIConditionalExpressionStateObjectBuilderto build theWHENclauses.- Specified by:
getCaseBuilderin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Returns:
- The builder of a
CASEexpression
-
getParent
protected StateObject getParent()
Returns the parent of the expression to build, which is only required when a JPQL fragment needs to be parsed.- Returns:
- The parent
-
index
public T index(String variable)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionINDEX(identification_variable).- Specified by:
indexin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
variable- The identification variable- Returns:
- This This builder
-
length
public T length(T builder)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionLENGTH(expression).- Specified by:
lengthin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
builder- The encapsulated expression- Returns:
- This This builder
-
literal
protected StateObject literal(String literal)
-
literals
protected List<StateObject> literals(String... literals)
-
locate
public T locate(T parameter1, T parameter2)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionLOCATE(string_primary, string_primary).- Specified by:
locatein interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
parameter1- The first string primaryparameter2- The second string primary- Returns:
- This This builder
-
locate
public T locate(T parameter1, T parameter2, T parameter3)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionLOCATE(string_primary, string_primary [, simple_arithmetic_expression]).- Specified by:
locatein interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
parameter1- The first string primaryparameter2- The second string primaryparameter3- The position of the search within the string- Returns:
- This This builder
-
max
protected void max(boolean distinct, String path)
-
max
public T max(String path)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionMAX(path).- Specified by:
maxin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
path- The state field path expression- Returns:
- This This builder
-
maxDistinct
public T maxDistinct(String path)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionMAX(DISTINCT path).- Specified by:
maxDistinctin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
path- The state field path expression- Returns:
- This This builder
-
min
protected void min(boolean distinct, String path)
-
min
public T min(String path)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionAVG(path).- Specified by:
minin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
path- The state field path expression- Returns:
- This This builder
-
minDistinct
public T minDistinct(String path)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionAVG(DISTINCT path).- Specified by:
minDistinctin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
path- The state field path expression- Returns:
- This This builder
-
minus
public T minus(T builder)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expression- x.- Specified by:
minusin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
builder- The expression that will have the plus sign prepended- Returns:
- This This builder
-
mod
public T mod(T parameter1, T parameter2)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionMOD(simple_arithmetic_expression, simple_arithmetic_expression).- Specified by:
modin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
parameter1- The first parameterparameter2- The second parameter- Returns:
- This This builder
-
multiply
public T multiply(T builder)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionx * y.- Specified by:
multiplyin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
builder- The right side of the multiply expression- Returns:
- This This builder
-
nullIf
public T nullIf(T builder1, T builder2)
Description copied from interface:IScalarExpressionStateObjectBuilderCreate the expressionNULLIF(scalar_expression, scalar_expression).- Specified by:
nullIfin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
builder1- The first scalar expressionbuilder2- The second scalar expression- Returns:
- This This builder
-
numeric
public T numeric(Number number)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the numeric literal.- Specified by:
numericin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
number- The numeric literal- Returns:
- This This builder
-
numeric
public T numeric(String number)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the numeric literal.- Specified by:
numericin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
number- The numeric literal- Returns:
- This This builder
-
parameter
public T parameter(String parameter)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the input parameter.- Specified by:
parameterin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
parameter- The named or positional input parameter- Returns:
- This This builder
-
path
public T path(String path)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates a new state field path expression.- Specified by:
pathin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
path- The state field path path expression- Returns:
- This This builder
-
plus
public T plus(T builder)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expression+ x.- Specified by:
plusin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
builder- The expression that will have the plus sign prepended- Returns:
- This This builder
-
size
public T size(String path)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionSIZE(collection_valued_path_expression).- Specified by:
sizein interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
path- The collection-valued path expression- Returns:
- This This builder
-
sqrt
public T sqrt(T builder)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionSQRT(x).- Specified by:
sqrtin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
builder- The parameter of theABSexpression- Returns:
- This This builder
-
stateObjects
protected List<StateObject> stateObjects(int count)
Returns a list of theStateObjectsthat were previously created.- Parameters:
count- The number ofStateObjectsto move to the list- Returns:
- The list of
StateObjectsthat were added to the stack
-
stateObjects
protected List<StateObject> stateObjects(T... builders)
Returns a list of theStateObjectsthat were previously created.- Parameters:
builders- The list ofbuildersis used to determine how manyStateObjectsneeds to be pulled out of the stack- Returns:
- The list of
StateObjectsthat were added to the stack
-
string
public T string(String literal)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates a new string literal.- Specified by:
stringin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
literal- The string literal- Returns:
- This This builder
-
sub
public T sub(T builder)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates an encapsulated expression:(expression).- Specified by:
subin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
builder- The expression that will be encapsulated- Returns:
- This This builder
-
subtract
public T subtract(T builder)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionx - y.- Specified by:
subtractin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
builder- The right side of the addition expression- Returns:
- This This builder
-
sum
protected void sum(boolean distinct, String path)
-
sum
public T sum(String path)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionSUM(path).- Specified by:
sumin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
path- The state field path expression- Returns:
- This This builder
-
sumDistinct
public T sumDistinct(String path)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionSUM(path).- Specified by:
sumDistinctin interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
path- The state field path expression- Returns:
- This This builder
-
type
public T type(String path)
Description copied from interface:IScalarExpressionStateObjectBuilderCreates the expressionTYPE(identification_variable | single_valued_object_path_expression | input_parameter).- Specified by:
typein interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>- Parameters:
path- The identification variable or the input parameter- Returns:
- This This builder
-
-