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
.- Version:
- 2.4
- Author:
- Pascal Filion
- Since:
- 2.4
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractScalarExpressionStateObjectBuilder(StateObject parent)
Creates a newAbstractScalarExpressionStateObjectBuilder
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
abs(T builder)
Creates the expressionABS(x)
.T
add(T builder)
Creates the expressionx + y
.protected void
arithmetic(boolean plusSign)
protected void
avg(boolean distinct, java.lang.String path)
T
avg(java.lang.String path)
Creates the expressionAVG(path)
.T
avgDistinct(java.lang.String path)
Creates the expressionAVG(DISTINCT path)
.protected StateObject
buildCollectionPath(java.lang.String path)
protected StateObject
buildIdentificationVariable(java.lang.String literal)
protected StateObject
buildInputParameter(java.lang.String parameter)
protected StateObject
buildNumeric(java.lang.Number number)
protected StateObject
buildNumeric(java.lang.String number)
protected StateObject
buildStateFieldPath(java.lang.String path)
protected StateObject
buildStringLiteral(java.lang.String literal)
T
case_(ICaseExpressionStateObjectBuilder builder)
Creates a newCASE
expression.T
coalesce(T builder1, T builder2, T... builders)
Create the expressionCOALESCE(scalar_expression {, scalar_expression}+)
.T
concat(T builder1, T builder2, T... builders)
Creates the expressionCONCAT(string_primary, string_primary {, string_primary}*)
.protected void
count(boolean distinct, java.lang.String path)
T
count(java.lang.String path)
Creates the expressionCOUNT(identification_variable | state_field_path_expression | single_valued_object_path_expression)
.T
countDistinct(java.lang.String path)
Creates the expressionCOUNT(DISTINCT identification_variable | state_field_path_expression | single_valued_object_path_expression)
.T
currentDate()
Creates the expression representingCURRENT_DATE
.T
currentTime()
Creates the expression representingCURRENT_TIME
.T
currentTimestamp()
Creates the expression representingCURRENT_TIMESTAMP
.T
date(java.lang.String jdbcDate)
Creates a new date using the JDBC syntax of a date.T
divide(T builder)
Creates the expressionx / y
.T
entityType(java.lang.String entityTypeName)
Creates a new entity type literal.T
enumLiteral(java.lang.Enum<? extends java.lang.Enum<?>> enumConstant)
Creates a new enum literal.T
function(java.lang.String identifier, java.lang.String functionName, java.lang.String... arguments)
Creates the expression<identifier>('functionName' {, expression}*)
.T
function(java.lang.String identifier, java.lang.String functionName, T... arguments)
Creates the expression<identifier>('functionName' {, expression}*)
.ICaseExpressionStateObjectBuilder
getCaseBuilder()
Returns the builder that can create aCASE
expression, which requires aIConditionalExpressionStateObjectBuilder
to build theWHEN
clauses.protected StateObject
getParent()
Returns the parent of the expression to build, which is only required when a JPQL fragment needs to be parsed.T
index(java.lang.String variable)
Creates the expressionINDEX(identification_variable)
.T
length(T builder)
Creates the expressionLENGTH(expression)
.protected StateObject
literal(java.lang.String literal)
protected java.util.List<StateObject>
literals(java.lang.String... literals)
T
locate(T parameter1, T parameter2)
Creates the expressionLOCATE(string_primary, string_primary)
.T
locate(T parameter1, T parameter2, T parameter3)
Creates the expressionLOCATE(string_primary, string_primary [, simple_arithmetic_expression])
.protected void
max(boolean distinct, java.lang.String path)
T
max(java.lang.String path)
Creates the expressionMAX(path)
.T
maxDistinct(java.lang.String path)
Creates the expressionMAX(DISTINCT path)
.protected void
min(boolean distinct, java.lang.String path)
T
min(java.lang.String path)
Creates the expressionAVG(path)
.T
minDistinct(java.lang.String path)
Creates the expressionAVG(DISTINCT path)
.T
minus(T builder)
Creates the expression- x
.T
mod(T parameter1, T parameter2)
Creates the expressionMOD(simple_arithmetic_expression, simple_arithmetic_expression)
.T
multiply(T builder)
Creates the expressionx * y
.T
nullIf(T builder1, T builder2)
Create the expressionNULLIF(scalar_expression, scalar_expression)
.T
numeric(java.lang.Number number)
Creates the numeric literal.T
numeric(java.lang.String number)
Creates the numeric literal.T
parameter(java.lang.String parameter)
Creates the input parameter.T
path(java.lang.String path)
Creates a new state field path expression.T
plus(T builder)
Creates the expression+ x
.T
size(java.lang.String path)
Creates the expressionSIZE(collection_valued_path_expression)
.T
sqrt(T builder)
Creates the expressionSQRT(x)
.protected java.util.List<StateObject>
stateObjects(int count)
Returns a list of theStateObjects
that were previously created.protected java.util.List<StateObject>
stateObjects(T... builders)
Returns a list of theStateObjects
that were previously created.T
string(java.lang.String literal)
Creates a new string literal.T
sub(T builder)
Creates an encapsulated expression:(expression)
.T
subtract(T builder)
Creates the expressionx - y
.protected void
sum(boolean distinct, java.lang.String path)
T
sum(java.lang.String path)
Creates the expressionSUM(path)
.T
sumDistinct(java.lang.String path)
Creates the expressionSUM(path)
.T
type(java.lang.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)
Creates the expressionABS(x)
.- Specified by:
abs
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
builder
- The parameter of theABS
expression- Returns:
- This This builder
-
add
public T add(T builder)
Creates the expressionx + y
.- Specified by:
add
in 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, java.lang.String path)
-
avg
public T avg(java.lang.String path)
Creates the expressionAVG(path)
.- Specified by:
avg
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
path
- The state field path expression- Returns:
- This This builder
-
avgDistinct
public T avgDistinct(java.lang.String path)
Creates the expressionAVG(DISTINCT path)
.- Specified by:
avgDistinct
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
path
- The state field path expression- Returns:
- This This builder
-
buildCollectionPath
protected StateObject buildCollectionPath(java.lang.String path)
-
buildIdentificationVariable
protected StateObject buildIdentificationVariable(java.lang.String literal)
-
buildInputParameter
protected StateObject buildInputParameter(java.lang.String parameter)
-
buildNumeric
protected StateObject buildNumeric(java.lang.Number number)
-
buildNumeric
protected StateObject buildNumeric(java.lang.String number)
-
buildStateFieldPath
protected StateObject buildStateFieldPath(java.lang.String path)
-
buildStringLiteral
protected StateObject buildStringLiteral(java.lang.String literal)
-
case_
public T case_(ICaseExpressionStateObjectBuilder builder)
Creates a newCASE
expression.- Specified by:
case_
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
builder
- Thebuilder
of aCASE
expression- Returns:
- This This builder
-
coalesce
public T coalesce(T builder1, T builder2, T... builders)
Create the expressionCOALESCE(scalar_expression {, scalar_expression}+)
.- Specified by:
coalesce
in 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)
Creates the expressionCONCAT(string_primary, string_primary {, string_primary}*)
.- Specified by:
concat
in 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, java.lang.String path)
-
count
public T count(java.lang.String path)
Creates the expressionCOUNT(identification_variable | state_field_path_expression | single_valued_object_path_expression)
.- Specified by:
count
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
path
- The state field path expression- Returns:
- This This builder
-
countDistinct
public T countDistinct(java.lang.String path)
Creates the expressionCOUNT(DISTINCT identification_variable | state_field_path_expression | single_valued_object_path_expression)
.- Specified by:
countDistinct
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
path
- The state field path expression- Returns:
- This This builder
-
currentDate
public T currentDate()
Creates the expression representingCURRENT_DATE
.- Specified by:
currentDate
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Returns:
- This This builder
-
currentTime
public T currentTime()
Creates the expression representingCURRENT_TIME
.- Specified by:
currentTime
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Returns:
- This This builder
-
currentTimestamp
public T currentTimestamp()
Creates the expression representingCURRENT_TIMESTAMP
.- Specified by:
currentTimestamp
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Returns:
- This This builder
-
date
public T date(java.lang.String jdbcDate)
Creates a new date using the JDBC syntax of a date.- Specified by:
date
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Returns:
- This This builder
-
divide
public T divide(T builder)
Creates the expressionx / y
.- Specified by:
divide
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
builder
- The right side of the division expression- Returns:
- This This builder
-
entityType
public T entityType(java.lang.String entityTypeName)
Creates a new entity type literal.- Specified by:
entityType
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
entityTypeName
- The short name of the entity- Returns:
- This This builder
-
enumLiteral
public T enumLiteral(java.lang.Enum<? extends java.lang.Enum<?>> enumConstant)
Creates a new enum literal.- Specified by:
enumLiteral
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
enumConstant
- The enum constant- Returns:
- This This builder
-
function
public T function(java.lang.String identifier, java.lang.String functionName, java.lang.String... arguments)
Creates the expression<identifier>('functionName' {, expression}*)
.- Specified by:
function
in 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(java.lang.String identifier, java.lang.String functionName, T... arguments)
Creates the expression<identifier>('functionName' {, expression}*)
.- Specified by:
function
in 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()
Returns the builder that can create aCASE
expression, which requires aIConditionalExpressionStateObjectBuilder
to build theWHEN
clauses.- Specified by:
getCaseBuilder
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Returns:
- The builder of a
CASE
expression
-
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(java.lang.String variable)
Creates the expressionINDEX(identification_variable)
.- Specified by:
index
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
variable
- The identification variable- Returns:
- This This builder
-
length
public T length(T builder)
Creates the expressionLENGTH(expression)
.- Specified by:
length
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
builder
- The encapsulated expression- Returns:
- This This builder
-
literal
protected StateObject literal(java.lang.String literal)
-
literals
protected java.util.List<StateObject> literals(java.lang.String... literals)
-
locate
public T locate(T parameter1, T parameter2)
Creates the expressionLOCATE(string_primary, string_primary)
.- Specified by:
locate
in 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)
Creates the expressionLOCATE(string_primary, string_primary [, simple_arithmetic_expression])
.- Specified by:
locate
in 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, java.lang.String path)
-
max
public T max(java.lang.String path)
Creates the expressionMAX(path)
.- Specified by:
max
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
path
- The state field path expression- Returns:
- This This builder
-
maxDistinct
public T maxDistinct(java.lang.String path)
Creates the expressionMAX(DISTINCT path)
.- Specified by:
maxDistinct
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
path
- The state field path expression- Returns:
- This This builder
-
min
protected void min(boolean distinct, java.lang.String path)
-
min
public T min(java.lang.String path)
Creates the expressionAVG(path)
.- Specified by:
min
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
path
- The state field path expression- Returns:
- This This builder
-
minDistinct
public T minDistinct(java.lang.String path)
Creates the expressionAVG(DISTINCT path)
.- Specified by:
minDistinct
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
path
- The state field path expression- Returns:
- This This builder
-
minus
public T minus(T builder)
Creates the expression- x
.- Specified by:
minus
in 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)
Creates the expressionMOD(simple_arithmetic_expression, simple_arithmetic_expression)
.- Specified by:
mod
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
parameter1
- The first parameterparameter2
- The second parameter- Returns:
- This This builder
-
multiply
public T multiply(T builder)
Creates the expressionx * y
.- Specified by:
multiply
in 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)
Create the expressionNULLIF(scalar_expression, scalar_expression)
.- Specified by:
nullIf
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
builder1
- The first scalar expressionbuilder2
- The second scalar expression- Returns:
- This This builder
-
numeric
public T numeric(java.lang.Number number)
Creates the numeric literal.- Specified by:
numeric
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
number
- The numeric literal- Returns:
- This This builder
-
numeric
public T numeric(java.lang.String number)
Creates the numeric literal.- Specified by:
numeric
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
number
- The numeric literal- Returns:
- This This builder
-
parameter
public T parameter(java.lang.String parameter)
Creates the input parameter.- Specified by:
parameter
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
parameter
- The named or positional input parameter- Returns:
- This This builder
-
path
public T path(java.lang.String path)
Creates a new state field path expression.- Specified by:
path
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
path
- The state field path path expression- Returns:
- This This builder
-
plus
public T plus(T builder)
Creates the expression+ x
.- Specified by:
plus
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
builder
- The expression that will have the plus sign prepended- Returns:
- This This builder
-
size
public T size(java.lang.String path)
Creates the expressionSIZE(collection_valued_path_expression)
.- Specified by:
size
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
path
- The collection-valued path expression- Returns:
- This This builder
-
sqrt
public T sqrt(T builder)
Creates the expressionSQRT(x)
.- Specified by:
sqrt
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
builder
- The parameter of theABS
expression- Returns:
- This This builder
-
stateObjects
protected java.util.List<StateObject> stateObjects(int count)
Returns a list of theStateObjects
that were previously created.- Parameters:
count
- The number ofStateObjects
to move to the list- Returns:
- The list of
StateObjects
that were added to the stack
-
stateObjects
protected java.util.List<StateObject> stateObjects(T... builders)
Returns a list of theStateObjects
that were previously created.- Parameters:
builders
- The list ofbuilders
is used to determine how manyStateObjects
needs to be pulled out of the stack- Returns:
- The list of
StateObjects
that were added to the stack
-
string
public T string(java.lang.String literal)
Creates a new string literal.- Specified by:
string
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
literal
- The string literal- Returns:
- This This builder
-
sub
public T sub(T builder)
Creates an encapsulated expression:(expression)
.- Specified by:
sub
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
builder
- The expression that will be encapsulated- Returns:
- This This builder
-
subtract
public T subtract(T builder)
Creates the expressionx - y
.- Specified by:
subtract
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
builder
- The right side of the addition expression- Returns:
- This This builder
-
sum
protected void sum(boolean distinct, java.lang.String path)
-
sum
public T sum(java.lang.String path)
Creates the expressionSUM(path)
.- Specified by:
sum
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
path
- The state field path expression- Returns:
- This This builder
-
sumDistinct
public T sumDistinct(java.lang.String path)
Creates the expressionSUM(path)
.- Specified by:
sumDistinct
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
path
- The state field path expression- Returns:
- This This builder
-
type
public T type(java.lang.String path)
Creates the expressionTYPE(identification_variable | single_valued_object_path_expression | input_parameter)
.- Specified by:
type
in interfaceIScalarExpressionStateObjectBuilder<T extends IScalarExpressionStateObjectBuilder<T>>
- Parameters:
path
- The identification variable or the input parameter- Returns:
- This This builder
-
-