Class ConstantExpressionTemplate
- All Implemented Interfaces:
ExpressionTemplate
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:
boolean
boolean
: Use as-isdouble
: 1 if true, else 0String
: Convert usingBoolean.toString(boolean)
double
boolean
: true if not zero, else falsedouble
: Use as-isString
: Convert usingInteger.toString(int)
if Integer orDouble.toString(double)
if Double
String
boolean
: Convert usingBoolean.parseBoolean(String)
double
: Convert usingDouble.parseDouble(String)
. Should it fail, uses length of StringString
: Use as-is
-
Constructor Summary
ConstructorDescriptionConstantExpressionTemplate
(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 theToBooleanExpression instance
this ExpressionTemplate holds.Returns theToDoubleExpression instance
this ExpressionTemplate holds.Returns theToStringExpression 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
and 0 for boolean valuefalse
.
ForToStringExpression'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 valuetrue
is used if the double value is anything but 0, otherwisefalse
.
ForToStringExpression'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 valueBoolean.parseBoolean(String)
is used.
ForToDoubleExpression'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 theToBooleanExpression instance
this ExpressionTemplate holds.- Specified by:
returnBooleanExpression
in interfaceExpressionTemplate
- Returns:
- The
ToBooleanExpression
stored in this ConstantExpressionTemplate.
-
returnDoubleExpression
Returns theToDoubleExpression instance
this ExpressionTemplate holds.- Specified by:
returnDoubleExpression
in interfaceExpressionTemplate
- Returns:
- The
ToDoubleExpression
stored in this ConstantExpressionTemplate.
-
returnStringExpression
Returns theToStringExpression instance
this ExpressionTemplate holds.- Specified by:
returnStringExpression
in interfaceExpressionTemplate
- Returns:
- The
ToStringExpression
stored in this ConstantExpressionTemplate.
-