Class ConstantExpressionTemplate
- All Implemented Interfaces:
ExpressionTemplate
An ExpressionTemplate instance that holds a ToBooleanExpression
,
ToDoubleExpression
and ToStringExpression
instance to call.
Static methods are available to create a new instance from a boolean, double or String respectively, with each having a different way of converting the provided value into the other outputs:
Input Output |
Boolean | Double | String |
---|---|---|---|
Boolean | Use as-is | true if not 0 , else false |
Converted using Boolean.parseBoolean(String) |
Double | 1.0 when true , else 0.0 |
Use as-is | Parsed using Double.parseDouble(String) Should it fail uses String length |
String | Converted using Boolean.toString(boolean) |
Converted using Integer.toString(int) if Integer, else Double.toString(double) |
Use as-is |
-
Constructor Summary
ConstructorsConstructorDescriptionConstantExpressionTemplate
(boolean booleanValue, double doubleValue, String stringValue) Constructor for creating a new ConstantExpressionTemplate. -
Method Summary
Modifier and TypeMethodDescriptionstatic ConstantExpressionTemplate
of
(boolean booleanValue) Creates a new ConstantExpressionTemplate using the provided boolean value.static ConstantExpressionTemplate
of
(double doubleValue) Creates a new ConstantExpressionTemplate using the provided double value.static ConstantExpressionTemplate
Creates a new ConstantExpressionTemplate using the provided String value.Returns the ToBooleanExpression instance this ExpressionTemplate holds.Returns the ToDoubleExpression instance this ExpressionTemplate holds.Returns the ToStringExpression instance this ExpressionTemplate holds.
-
Constructor Details
-
ConstantExpressionTemplate
Constructor for creating a new ConstantExpressionTemplate.- Parameters:
booleanValue
- The boolean value to store.doubleValue
- The double value to store.stringValue
- The String value to store.
-
-
Method Details
-
of
Creates a new ConstantExpressionTemplate using the provided boolean value.
For ToDoubleExpression's double value is
1
used for boolean valuetrue
and0
for boolean valuefalse
.
For ToStringExpression's String value isBoolean.toString(boolean)
used.- Parameters:
booleanValue
- The boolean value to use.- Returns:
- new ConstantExpressionTemplate holding the ToBooleanExpression, ToDoubleExpression and ToStringExpression instances.
-
of
Creates a new ConstantExpressionTemplate using the provided double value.
For ToBooleanExperssion's boolean value
true
is used if the double value is anything but 0, otherwisefalse
.
For ToStringExpression's String valueInteger.toString(int)
orDouble.toString(double)
is used depending on if the double can be cast to integer.- Parameters:
doubleValue
- The double value to use.- Returns:
- new ConstantExpressionTemplate holding the ToBooleanExpression, ToDoubleExpression and ToStringExpression instances.
-
of
Creates a new ConstantExpressionTemplate using the provided String value.
For ToBooleanExpression's boolean value
Boolean.parseBoolean(String)
is used.
For ToDoubleExpression's double valueDouble.parseDouble(String)
is used. In case of an exception happening, the String's length is used instead.- Parameters:
stringValue
- The String value to use.- Returns:
- new ConstantExpressionTemplate holding the ToBooleanExpression, ToDoubleExpression and ToStringExpression instances.
-
returnBooleanExpression
Returns the ToBooleanExpression instance this ExpressionTemplate holds.- Specified by:
returnBooleanExpression
in interfaceExpressionTemplate
- Returns:
- The
ToBooleanExpression
stored in this ConstantExpressionTemplate.
-
returnDoubleExpression
Returns the ToDoubleExpression instance this ExpressionTemplate holds.- Specified by:
returnDoubleExpression
in interfaceExpressionTemplate
- Returns:
- The
ToDoubleExpression
stored in this ConstantExpressionTemplate.
-
returnStringExpression
Returns the ToStringExpression instance this ExpressionTemplate holds.- Specified by:
returnStringExpression
in interfaceExpressionTemplate
- Returns:
- The
ToStringExpression
stored in this ConstantExpressionTemplate.
-