
Data Types
|
Data Types |
Explanation |
|---|---|
|
Integer Literal |
Any numeric literal with no fraction is treated as Integer Literal. For example: 3, 27. The default literal type for integer literal is int. You can designate an integer literal as long by suffixing 'l' or 'L' to the value. For example: 200L, 5000l |
|
Floating Point Literal |
Any numeric literal with fraction is considered as Floating type literal. Ex. 3.0, 27.0 You can also specify a floating point in scientific notation by using exponent 'E' or 'e'. For example: 0.03E2. The default literal type for floating type literal is double. You can designate a literal as float by using the suffix 'f' or 'F'. For example: 200.0f, 5000.0F. You can also represent a literal as double by the optional suffix 'd' or 'D'. For example: 3.0d, 27.0D |
|
Boolean Literal |
You can represent Boolean literals by using the keywords true and false. |
|
Character Literal |
You can represent a character literal by a single character delimited by single quotes. For example: 'a' |
|
String Literal |
String literal is a sequence of characters which has to be single quoted. Example
'The quick brown fox'. The usage of single quote within the String has to be used with escape sequence '\' to avoid confusion as to where the String ends. |
|
Date Literal |
Date literal is a date representation in the xsd: date format yyyy-mm-dd within a single quote |
|
Escape Character |
The escape character is a character which provides alternate interpretation of a character in a character sequence. The escape character is backslash '\' |
Identifiers
|
Variable Name |
Each variable name is a sequence of characters delimited by double quotes Example
"name", "int1", "this is a variable". The variable name has to escape the usage of literal delimiters such as single quote, double quote and backslash. |
|
Aliases |
Each alias name is a sequence of character delimited by double quotes. Example
"new ArrayList" An alias can have arguments interpolated within the name. Each argument interpolation is delimited by open and close parenthesis. For example "Grant a loan of (1000)", "Compare (10) and (20)" If an Alias name have a sequence of arguments interpolated, the arguments can be given within a single parentheses separated by commas. Set Employee Name {String} {String} {String} "Set Employee Name("First Name", "Middle Name", "Last Name")" General Usage "Set Employee Name("First Name") ("Middle Name") ("Last Name")" The usage of parentheses/delimiters within the alias name has to be escaped. For example "Check\" \(Credit\)" |
Expressions and their Usage
|
Expression as Argument |
An argument in an Alias Name can have expression. So an alias name can have literal or variable name as an argument. Example
"Grant a loan of ("Loan Amount")"," Compare ("Loan Amount") and (1000)" An argument can also have numeric operand expression. "Grant a loan of ( "Loan Amount" + 1000)" "Compare ("Loan Amount" + 1000) and (2000 + 1000)" "Compare (("Loan Amount" + 1000)*2) and ((2000 + 1000)*2)" |
|
Other Condition |
A simple condition is a condition which has left and right expression with relational comparators in between. The list of comparators available are Equals, Not Equals, Greater Than Equals, Greater Than, Less Than Equals, Less Than, Like, Not Like, In and Not In. Ex. Example
"Compare("Loan Amount") and (2000)" Equals 0. An 'And'/'or' condition is a condition which has a left condition and a right condition with either 'and'/'or' logical operator in between. 'And' condition can be given like "Compare("Loan Amount") and (2000)" Equals 0 and "Grant a loan of ("Loan Amount")" Equals true. 'Or' condition can be given like "Compare("Loan Amount") and (2000)" Equals 0 or "Grant a loan of ("Loan Amount")" Equals true 'and'/'or' condition will always add a curly braces around it. The above condition will be represented in the editor as { "Compare("Loan Amount") and (2000)" Equals 0 or "Grant a loan of ("Loan Amount")" Equals true} A Complex Condition is a condition which has a mix of 'and'/'or' conditions and simple conditions { "Compare("Loan Amount") and (2000)" Equals 0 or { "Grant a loan of ("Loan Amount")" Equals true And "Interest Rate of("Loan Amount") for ("years")" Greater Than 20 } } |
Best Practices
You must avoid having Overloaded Alias name.
When having overloaded alias name, the alias name resolved while creating the conditions object might map to a different alias from the one expected. The Java Language Specification is applied to resolve the method aliases.
When an overloaded Alias argument differs only by primitive and its wrapper type.
Compare {int} and {int} Compare {Integer} and {Integer}
The usage of 'int' literal in the arguments will always resolve the Alias with primitive 'int' as argument.
The Alias with wrapper arguments will never be resolved for a literal input.
"Compare (1000) and (1000)
You must always use suffixes to mark the type of the literal.
Grant Loan {int}
Grant Loan {long}
A long value should be represented as 1000L.
An input of "Grant Loan(1000)" will always resolve to 'int' type as per the Literal definition. If the 'long' type has to be resolved the input should be "Grant Loan(1000L)". The suffix of long makes the parser to treat the literal as 'long' instead of the default numeric literal 'int' .
The basic unit of numeric literal in the specification is 'int', so any alias having an argument of type byte cannot be resolved with literal.
You must always use curly braces to group conditions.
If you do not group conditions, then the Rules Composer will decide the grouping.
Input:
"(0)as string" Equals 'Default Value' and "(0)as string" Equals 'Default Value' or "Boolean.TRUE" Equals true
Grouped Condition Input:
"(0)as string" Equals 'Default Value' and
{
"(0)as string" Equals 'Default Value' or "Boolean.TRUE" Equals true
}