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 ConstantExpressionTemplateof(boolean booleanValue) Creates a new ConstantExpressionTemplate using the provided boolean value.static ConstantExpressionTemplateof(double doubleValue) Creates a new ConstantExpressionTemplate using the provided double value.static ConstantExpressionTemplateCreates 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
1used for boolean valuetrueand0for 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
trueis 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:
returnBooleanExpressionin interfaceExpressionTemplate- Returns:
- The
ToBooleanExpressionstored in this ConstantExpressionTemplate.
-
returnDoubleExpression
Returns the ToDoubleExpression instance this ExpressionTemplate holds.- Specified by:
returnDoubleExpressionin interfaceExpressionTemplate- Returns:
- The
ToDoubleExpressionstored in this ConstantExpressionTemplate.
-
returnStringExpression
Returns the ToStringExpression instance this ExpressionTemplate holds.- Specified by:
returnStringExpressionin interfaceExpressionTemplate- Returns:
- The
ToStringExpressionstored in this ConstantExpressionTemplate.
-