@fincity/kirun-js 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/.prettierrc +9 -0
  2. package/__tests__/engine/function/system/array/AddFirstTest.ts +235 -0
  3. package/__tests__/engine/function/system/array/AddTest.ts +126 -0
  4. package/__tests__/engine/function/system/array/BinarySearchTest.ts +135 -0
  5. package/__tests__/engine/function/system/array/CompareTest.ts +48 -0
  6. package/__tests__/engine/function/system/array/CopyTest.ts +86 -0
  7. package/__tests__/engine/function/system/array/DeleteFirstTest.ts +103 -0
  8. package/__tests__/engine/function/system/array/DeleteFromTest.ts +232 -0
  9. package/__tests__/engine/function/system/array/DeleteLastTest.ts +103 -0
  10. package/__tests__/engine/function/system/array/DeleteTest.ts +110 -0
  11. package/__tests__/engine/function/system/array/DisjointTest.ts +184 -0
  12. package/__tests__/engine/function/system/array/Equals.ts +67 -0
  13. package/__tests__/engine/function/system/array/FillTest.ts +36 -0
  14. package/__tests__/engine/function/system/array/FrequencyTest.ts +97 -0
  15. package/__tests__/engine/function/system/array/IndexOfArrayTest.ts +347 -0
  16. package/__tests__/engine/function/system/array/IndexOfTest.ts +267 -0
  17. package/__tests__/engine/function/system/array/InsertTest.ts +229 -0
  18. package/__tests__/engine/function/system/array/LastIndexOfArrayTest.ts +213 -0
  19. package/__tests__/engine/function/system/array/LastIndexOfTest.ts +253 -0
  20. package/__tests__/engine/function/system/array/MaxTest.ts +98 -0
  21. package/__tests__/engine/function/system/array/MinTest.ts +99 -0
  22. package/__tests__/engine/function/system/array/MisMatchTest.ts +215 -0
  23. package/__tests__/engine/function/system/array/ReverseTest.ts +235 -0
  24. package/__tests__/engine/function/system/array/RotateTest.ts +137 -0
  25. package/__tests__/engine/function/system/array/ShuffleTest.ts +154 -0
  26. package/__tests__/engine/function/system/array/SortTest.ts +130 -0
  27. package/__tests__/engine/function/system/array/SubArrayTest.ts +236 -0
  28. package/__tests__/engine/function/system/math/AddTest.ts +12 -0
  29. package/__tests__/engine/function/system/string/ConcatenateTest.ts +46 -0
  30. package/__tests__/engine/function/system/string/DeleteForGivenLengthTest.ts +38 -0
  31. package/__tests__/engine/function/system/string/InsertAtGivenPositionTest.ts +53 -0
  32. package/__tests__/engine/function/system/string/PostPadTest.ts +54 -0
  33. package/__tests__/engine/function/system/string/PrePadTest.ts +54 -0
  34. package/__tests__/engine/function/system/string/RegionMatchesTest.ts +78 -0
  35. package/__tests__/engine/function/system/string/ReverseTest.ts +36 -0
  36. package/__tests__/engine/function/system/string/SplitTest.ts +61 -0
  37. package/__tests__/engine/function/system/string/StringFunctionRepoTest2.ts +126 -0
  38. package/__tests__/engine/function/system/string/StringFunctionRepoTest3.ts +54 -0
  39. package/__tests__/engine/function/system/string/StringFunctionRepositoryTest.ts +146 -0
  40. package/__tests__/engine/function/system/string/ToStringTest.ts +43 -0
  41. package/__tests__/engine/function/system/string/TrimToTest.ts +28 -0
  42. package/__tests__/engine/json/schema/validator/SchemaValidatorTest.ts +26 -0
  43. package/__tests__/engine/runtime/KIRuntimeTest.ts +351 -0
  44. package/__tests__/engine/runtime/expression/ExpressionEvaluationTest.ts +128 -0
  45. package/__tests__/engine/runtime/expression/ExpressionTest.ts +33 -0
  46. package/__tests__/engine/runtime/expression/tokenextractor/OutputMapTokenValueExtractorTest.ts +44 -0
  47. package/__tests__/engine/runtime/expression/tokenextractor/TokenValueExtractorTest.ts +72 -0
  48. package/__tests__/engine/util/LinkedListTest.ts +29 -0
  49. package/__tests__/engine/util/string/StringFormatterTest.ts +17 -0
  50. package/__tests__/indexTest.ts +33 -0
  51. package/dist/index.js +2 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/module.js +2 -0
  54. package/dist/module.js.map +1 -0
  55. package/dist/types.d.ts +430 -0
  56. package/dist/types.d.ts.map +1 -0
  57. package/package.json +54 -0
  58. package/src/engine/HybridRepository.ts +18 -0
  59. package/src/engine/Repository.ts +3 -0
  60. package/src/engine/constant/KIRunConstants.ts +7 -0
  61. package/src/engine/exception/ExecutionException.ts +12 -0
  62. package/src/engine/exception/KIRuntimeException.ts +12 -0
  63. package/src/engine/function/AbstractFunction.ts +76 -0
  64. package/src/engine/function/Function.ts +13 -0
  65. package/src/engine/function/system/GenerateEvent.ts +76 -0
  66. package/src/engine/function/system/If.ts +40 -0
  67. package/src/engine/function/system/array/AbstractArrayFunction.ts +158 -0
  68. package/src/engine/function/system/array/Add.ts +31 -0
  69. package/src/engine/function/system/array/AddFirst.ts +44 -0
  70. package/src/engine/function/system/array/BinarySearch.ts +66 -0
  71. package/src/engine/function/system/array/Compare.ts +150 -0
  72. package/src/engine/function/system/array/Copy.ts +56 -0
  73. package/src/engine/function/system/array/Delete.ts +63 -0
  74. package/src/engine/function/system/array/DeleteFirst.ts +22 -0
  75. package/src/engine/function/system/array/DeleteFrom.ts +51 -0
  76. package/src/engine/function/system/array/DeleteLast.ts +23 -0
  77. package/src/engine/function/system/array/Disjoint.ts +85 -0
  78. package/src/engine/function/system/array/Equals.ts +36 -0
  79. package/src/engine/function/system/array/Fill.ts +51 -0
  80. package/src/engine/function/system/array/Frequency.ts +68 -0
  81. package/src/engine/function/system/array/IndexOf.ts +56 -0
  82. package/src/engine/function/system/array/IndexOfArray.ts +67 -0
  83. package/src/engine/function/system/array/Insert.ts +48 -0
  84. package/src/engine/function/system/array/LastIndexOf.ts +62 -0
  85. package/src/engine/function/system/array/LastIndexOfArray.ts +70 -0
  86. package/src/engine/function/system/array/Max.ts +31 -0
  87. package/src/engine/function/system/array/Min.ts +32 -0
  88. package/src/engine/function/system/array/MisMatch.ts +66 -0
  89. package/src/engine/function/system/array/Reverse.ts +50 -0
  90. package/src/engine/function/system/array/Rotate.ts +43 -0
  91. package/src/engine/function/system/array/Shuffle.ts +31 -0
  92. package/src/engine/function/system/array/Sort.ts +70 -0
  93. package/src/engine/function/system/array/SubArray.ts +48 -0
  94. package/src/engine/function/system/context/Create.ts +73 -0
  95. package/src/engine/function/system/context/Get.ts +55 -0
  96. package/src/engine/function/system/context/SetFunction.ts +244 -0
  97. package/src/engine/function/system/loop/CountLoop.ts +55 -0
  98. package/src/engine/function/system/loop/RangeLoop.ts +120 -0
  99. package/src/engine/function/system/math/Add.ts +34 -0
  100. package/src/engine/function/system/math/GenericMathFunction.ts +80 -0
  101. package/src/engine/function/system/math/Hypotenuse.ts +57 -0
  102. package/src/engine/function/system/math/MathFunctionRepository.ts +63 -0
  103. package/src/engine/function/system/math/Maximum.ts +38 -0
  104. package/src/engine/function/system/math/Minimum.ts +38 -0
  105. package/src/engine/function/system/math/Random.ts +27 -0
  106. package/src/engine/function/system/string/AbstractStringFunction.ts +409 -0
  107. package/src/engine/function/system/string/Concatenate.ts +57 -0
  108. package/src/engine/function/system/string/DeleteForGivenLength.ts +82 -0
  109. package/src/engine/function/system/string/InsertAtGivenPosition.ts +72 -0
  110. package/src/engine/function/system/string/PostPad.ts +83 -0
  111. package/src/engine/function/system/string/PrePad.ts +73 -0
  112. package/src/engine/function/system/string/RegionMatches.ts +119 -0
  113. package/src/engine/function/system/string/ReplaceAtGivenPosition.ts +101 -0
  114. package/src/engine/function/system/string/Reverse.ts +62 -0
  115. package/src/engine/function/system/string/Split.ts +53 -0
  116. package/src/engine/function/system/string/StringFunctionRepository.ts +60 -0
  117. package/src/engine/function/system/string/ToString.ts +45 -0
  118. package/src/engine/function/system/string/TrimTo.ts +55 -0
  119. package/src/engine/json/JsonExpression.ts +11 -0
  120. package/src/engine/json/schema/Schema.ts +670 -0
  121. package/src/engine/json/schema/SchemaUtil.ts +145 -0
  122. package/src/engine/json/schema/array/ArraySchemaType.ts +44 -0
  123. package/src/engine/json/schema/object/AdditionalPropertiesType.ts +32 -0
  124. package/src/engine/json/schema/string/StringFormat.ts +7 -0
  125. package/src/engine/json/schema/type/MultipleType.ts +28 -0
  126. package/src/engine/json/schema/type/SchemaType.ts +11 -0
  127. package/src/engine/json/schema/type/SingleType.ts +23 -0
  128. package/src/engine/json/schema/type/Type.ts +6 -0
  129. package/src/engine/json/schema/type/TypeUtil.ts +25 -0
  130. package/src/engine/json/schema/validator/AnyOfAllOfOneOfValidator.ts +108 -0
  131. package/src/engine/json/schema/validator/ArrayValidator.ts +145 -0
  132. package/src/engine/json/schema/validator/BooleanValidator.ts +24 -0
  133. package/src/engine/json/schema/validator/NullValidator.ts +17 -0
  134. package/src/engine/json/schema/validator/NumberValidator.ts +115 -0
  135. package/src/engine/json/schema/validator/ObjectValidator.ts +184 -0
  136. package/src/engine/json/schema/validator/SchemaValidator.ts +141 -0
  137. package/src/engine/json/schema/validator/StringValidator.ts +97 -0
  138. package/src/engine/json/schema/validator/TypeValidator.ts +49 -0
  139. package/src/engine/json/schema/validator/exception/SchemaReferenceException.ts +19 -0
  140. package/src/engine/json/schema/validator/exception/SchemaValidationException.ts +22 -0
  141. package/src/engine/model/AbstractStatement.ts +29 -0
  142. package/src/engine/model/Argument.ts +36 -0
  143. package/src/engine/model/Event.ts +62 -0
  144. package/src/engine/model/EventResult.ts +34 -0
  145. package/src/engine/model/FunctionDefinition.ts +69 -0
  146. package/src/engine/model/FunctionOutput.ts +37 -0
  147. package/src/engine/model/FunctionOutputGenerator.ts +5 -0
  148. package/src/engine/model/FunctionSignature.ts +67 -0
  149. package/src/engine/model/Parameter.ts +97 -0
  150. package/src/engine/model/ParameterReference.ts +57 -0
  151. package/src/engine/model/ParameterReferenceType.ts +4 -0
  152. package/src/engine/model/ParameterType.ts +4 -0
  153. package/src/engine/model/Position.ts +40 -0
  154. package/src/engine/model/Statement.ts +101 -0
  155. package/src/engine/model/StatementGroup.ts +37 -0
  156. package/src/engine/namespaces/Namespaces.ts +11 -0
  157. package/src/engine/repository/KIRunFunctionRepository.ts +37 -0
  158. package/src/engine/repository/KIRunSchemaRepository.ts +24 -0
  159. package/src/engine/runtime/ContextElement.ts +28 -0
  160. package/src/engine/runtime/FunctionExecutionParameters.ts +74 -0
  161. package/src/engine/runtime/KIRuntime.ts +653 -0
  162. package/src/engine/runtime/StatementExecution.ts +61 -0
  163. package/src/engine/runtime/StatementMessage.ts +30 -0
  164. package/src/engine/runtime/StatementMessageType.ts +5 -0
  165. package/src/engine/runtime/expression/Expression.ts +330 -0
  166. package/src/engine/runtime/expression/ExpressionEvaluator.ts +305 -0
  167. package/src/engine/runtime/expression/ExpressionToken.ts +15 -0
  168. package/src/engine/runtime/expression/ExpressionTokenValue.ts +23 -0
  169. package/src/engine/runtime/expression/Operation.ts +190 -0
  170. package/src/engine/runtime/expression/exception/ExpressionEvaluationException.ts +15 -0
  171. package/src/engine/runtime/expression/operators/binary/ArithmeticAdditionOperator.ts +9 -0
  172. package/src/engine/runtime/expression/operators/binary/ArithmeticDivisionOperator.ts +9 -0
  173. package/src/engine/runtime/expression/operators/binary/ArithmeticInetgerDivisionOperator.ts +9 -0
  174. package/src/engine/runtime/expression/operators/binary/ArithmeticModulusOperator.ts +9 -0
  175. package/src/engine/runtime/expression/operators/binary/ArithmeticMultiplicationOperator.ts +9 -0
  176. package/src/engine/runtime/expression/operators/binary/ArithmeticSubtractionOperator.ts +9 -0
  177. package/src/engine/runtime/expression/operators/binary/ArrayOperator.ts +31 -0
  178. package/src/engine/runtime/expression/operators/binary/BinaryOperator.ts +15 -0
  179. package/src/engine/runtime/expression/operators/binary/BitwiseAndOperator.ts +9 -0
  180. package/src/engine/runtime/expression/operators/binary/BitwiseLeftShiftOperator.ts +9 -0
  181. package/src/engine/runtime/expression/operators/binary/BitwiseOrOperator.ts +9 -0
  182. package/src/engine/runtime/expression/operators/binary/BitwiseRightShiftOperator.ts +9 -0
  183. package/src/engine/runtime/expression/operators/binary/BitwiseUnsignedRightShiftOperator.ts +9 -0
  184. package/src/engine/runtime/expression/operators/binary/BitwiseXorOperator.ts +9 -0
  185. package/src/engine/runtime/expression/operators/binary/LogicalAndOperator.ts +25 -0
  186. package/src/engine/runtime/expression/operators/binary/LogicalEqualOperator.ts +13 -0
  187. package/src/engine/runtime/expression/operators/binary/LogicalGreaterThanEqualOperator.ts +24 -0
  188. package/src/engine/runtime/expression/operators/binary/LogicalGreaterThanOperator.ts +24 -0
  189. package/src/engine/runtime/expression/operators/binary/LogicalLessThanEqualOperator.ts +24 -0
  190. package/src/engine/runtime/expression/operators/binary/LogicalLessThanOperator.ts +24 -0
  191. package/src/engine/runtime/expression/operators/binary/LogicalNotEqualOperator.ts +13 -0
  192. package/src/engine/runtime/expression/operators/binary/LogicalOrOperator.ts +25 -0
  193. package/src/engine/runtime/expression/operators/binary/ObjectOperator.ts +24 -0
  194. package/src/engine/runtime/expression/operators/unary/ArithmeticUnaryMinusOperator.ts +13 -0
  195. package/src/engine/runtime/expression/operators/unary/ArithmeticUnaryPlusOperator.ts +13 -0
  196. package/src/engine/runtime/expression/operators/unary/BitwiseComplementOperator.ts +22 -0
  197. package/src/engine/runtime/expression/operators/unary/LogicalNotOperator.ts +22 -0
  198. package/src/engine/runtime/expression/operators/unary/UnaryOperator.ts +15 -0
  199. package/src/engine/runtime/expression/tokenextractor/LiteralTokenValueExtractor.ts +64 -0
  200. package/src/engine/runtime/expression/tokenextractor/TokenValueExtractor.ts +136 -0
  201. package/src/engine/runtime/graph/ExecutionGraph.ts +81 -0
  202. package/src/engine/runtime/graph/GraphVertex.ts +118 -0
  203. package/src/engine/runtime/graph/GraphVertexType.ts +4 -0
  204. package/src/engine/runtime/tokenextractor/ArgumentsTokenValueExtractor.ts +22 -0
  205. package/src/engine/runtime/tokenextractor/ContextTokenValueExtractor.ts +37 -0
  206. package/src/engine/runtime/tokenextractor/OutputMapTokenValueExtractor.ts +32 -0
  207. package/src/engine/util/ArrayUtil.ts +23 -0
  208. package/src/engine/util/LinkedList.ts +229 -0
  209. package/src/engine/util/MapUtil.ts +86 -0
  210. package/src/engine/util/NullCheck.ts +3 -0
  211. package/src/engine/util/Tuples.ts +43 -0
  212. package/src/engine/util/primitive/PrimitiveUtil.ts +143 -0
  213. package/src/engine/util/string/StringBuilder.ts +59 -0
  214. package/src/engine/util/string/StringFormatter.ts +25 -0
  215. package/src/engine/util/string/StringUtil.ts +48 -0
  216. package/src/index.ts +13 -0
  217. package/tsconfig.json +6 -0
@@ -0,0 +1,305 @@
1
+ import { ExecutionException } from '../../exception/ExecutionException';
2
+ import { LinkedList } from '../../util/LinkedList';
3
+ import { StringBuilder } from '../../util/string/StringBuilder';
4
+ import { StringFormatter } from '../../util/string/StringFormatter';
5
+ import { FunctionExecutionParameters } from '../FunctionExecutionParameters';
6
+ import { ExpressionEvaluationException } from './exception/ExpressionEvaluationException';
7
+ import { Expression } from './Expression';
8
+ import { ExpressionToken } from './ExpressionToken';
9
+ import { ExpressionTokenValue } from './ExpressionTokenValue';
10
+ import { Operation } from './Operation';
11
+ import { ArithmeticAdditionOperator } from './operators/binary/ArithmeticAdditionOperator';
12
+ import { ArithmeticDivisionOperator } from './operators/binary/ArithmeticDivisionOperator';
13
+ import { ArithmeticIntegerDivisionOperator } from './operators/binary/ArithmeticInetgerDivisionOperator';
14
+ import { ArithmeticModulusOperator } from './operators/binary/ArithmeticModulusOperator';
15
+ import { ArithmeticMultiplicationOperator } from './operators/binary/ArithmeticMultiplicationOperator';
16
+ import { ArithmeticSubtractionOperator } from './operators/binary/ArithmeticSubtractionOperator';
17
+ import { ArrayOperator } from './operators/binary/ArrayOperator';
18
+ import { BinaryOperator } from './operators/binary/BinaryOperator';
19
+ import { BitwiseAndOperator } from './operators/binary/BitwiseAndOperator';
20
+ import { BitwiseLeftShiftOperator } from './operators/binary/BitwiseLeftShiftOperator';
21
+ import { BitwiseOrOperator } from './operators/binary/BitwiseOrOperator';
22
+ import { BitwiseRightShiftOperator } from './operators/binary/BitwiseRightShiftOperator';
23
+ import { BitwiseUnsignedRightShiftOperator } from './operators/binary/BitwiseUnsignedRightShiftOperator';
24
+ import { BitwiseXorOperator } from './operators/binary/BitwiseXorOperator';
25
+ import { LogicalAndOperator } from './operators/binary/LogicalAndOperator';
26
+ import { LogicalEqualOperator } from './operators/binary/LogicalEqualOperator';
27
+ import { LogicalGreaterThanEqualOperator } from './operators/binary/LogicalGreaterThanEqualOperator';
28
+ import { LogicalGreaterThanOperator } from './operators/binary/LogicalGreaterThanOperator';
29
+ import { LogicalLessThanEqualOperator } from './operators/binary/LogicalLessThanEqualOperator';
30
+ import { LogicalLessThanOperator } from './operators/binary/LogicalLessThanOperator';
31
+ import { LogicalNotEqualOperator } from './operators/binary/LogicalNotEqualOperator';
32
+ import { LogicalOrOperator } from './operators/binary/LogicalOrOperator';
33
+ import { ObjectOperator } from './operators/binary/ObjectOperator';
34
+ import { ArithmeticUnaryMinusOperator } from './operators/unary/ArithmeticUnaryMinusOperator';
35
+ import { ArithmeticUnaryPlusOperator } from './operators/unary/ArithmeticUnaryPlusOperator';
36
+ import { BitwiseComplementOperator } from './operators/unary/BitwiseComplementOperator';
37
+ import { LogicalNotOperator } from './operators/unary/LogicalNotOperator';
38
+ import { UnaryOperator } from './operators/unary/UnaryOperator';
39
+ import { LiteralTokenValueExtractor } from './tokenextractor/LiteralTokenValueExtractor';
40
+ import { TokenValueExtractor } from './tokenextractor/TokenValueExtractor';
41
+
42
+ export class ExpressionEvaluator {
43
+ private static readonly UNARY_OPERATORS_MAP: Map<Operation, UnaryOperator> = new Map([
44
+ [Operation.UNARY_BITWISE_COMPLEMENT, new BitwiseComplementOperator()],
45
+ [Operation.UNARY_LOGICAL_NOT, new LogicalNotOperator()],
46
+ [Operation.UNARY_MINUS, new ArithmeticUnaryMinusOperator()],
47
+ [Operation.UNARY_PLUS, new ArithmeticUnaryPlusOperator()],
48
+ ]);
49
+
50
+ private static readonly BINARY_OPERATORS_MAP: Map<Operation, BinaryOperator> = new Map([
51
+ [Operation.ADDITION, new ArithmeticAdditionOperator()],
52
+ [Operation.DIVISION, new ArithmeticDivisionOperator()],
53
+ [Operation.INTEGER_DIVISION, new ArithmeticIntegerDivisionOperator()],
54
+ [Operation.MOD, new ArithmeticModulusOperator()],
55
+ [Operation.MULTIPLICATION, new ArithmeticMultiplicationOperator()],
56
+ [Operation.SUBTRACTION, new ArithmeticSubtractionOperator()],
57
+
58
+ [Operation.BITWISE_AND, new BitwiseAndOperator()],
59
+ [Operation.BITWISE_LEFT_SHIFT, new BitwiseLeftShiftOperator()],
60
+ [Operation.BITWISE_OR, new BitwiseOrOperator()],
61
+ [Operation.BITWISE_RIGHT_SHIFT, new BitwiseRightShiftOperator()],
62
+ [Operation.BITWISE_UNSIGNED_RIGHT_SHIFT, new BitwiseUnsignedRightShiftOperator()],
63
+ [Operation.BITWISE_XOR, new BitwiseXorOperator()],
64
+
65
+ [Operation.AND, new LogicalAndOperator()],
66
+ [Operation.EQUAL, new LogicalEqualOperator()],
67
+ [Operation.GREATER_THAN, new LogicalGreaterThanOperator()],
68
+ [Operation.GREATER_THAN_EQUAL, new LogicalGreaterThanEqualOperator()],
69
+ [Operation.LESS_THAN, new LogicalLessThanOperator()],
70
+ [Operation.LESS_THAN_EQUAL, new LogicalLessThanEqualOperator()],
71
+ [Operation.OR, new LogicalOrOperator()],
72
+ [Operation.NOT_EQUAL, new LogicalNotEqualOperator()],
73
+
74
+ [Operation.ARRAY_OPERATOR, new ArrayOperator()],
75
+ [Operation.OBJECT_OPERATOR, new ObjectOperator()],
76
+ ]);
77
+
78
+ private static readonly UNARY_OPERATORS_MAP_KEY_SET: Set<Operation> = new Set(
79
+ ExpressionEvaluator.UNARY_OPERATORS_MAP.keys(),
80
+ );
81
+
82
+ private expression: string;
83
+ private exp?: Expression;
84
+
85
+ public constructor(exp: Expression | string) {
86
+ if (exp instanceof Expression) {
87
+ this.exp = exp as Expression;
88
+ this.expression = this.exp.getExpression();
89
+ } else {
90
+ this.expression = exp;
91
+ }
92
+ }
93
+
94
+ public evaluate(valuesMap: Map<string, TokenValueExtractor>): any {
95
+ if (!this.exp) this.exp = new Expression(this.expression);
96
+ return this.evaluateExpression(this.exp, valuesMap);
97
+ }
98
+
99
+ public getExpression(): Expression {
100
+ if (!this.exp) this.exp = new Expression(this.expression);
101
+
102
+ return this.exp;
103
+ }
104
+
105
+ public getExpressionString(): string {
106
+ return this.expression;
107
+ }
108
+
109
+ private evaluateExpression(exp: Expression, valuesMap: Map<string, TokenValueExtractor>): any {
110
+ let ops: LinkedList<Operation> = exp.getOperations();
111
+ let tokens: LinkedList<ExpressionToken> = exp.getTokens();
112
+
113
+ while (!ops.isEmpty()) {
114
+ let operator: Operation = ops.pop();
115
+ let token: ExpressionToken = tokens.pop();
116
+
117
+ if (ExpressionEvaluator.UNARY_OPERATORS_MAP_KEY_SET.has(operator)) {
118
+ tokens.push(
119
+ this.applyUnaryOperation(operator, this.getValueFromToken(valuesMap, token)),
120
+ );
121
+ } else if (
122
+ operator == Operation.OBJECT_OPERATOR ||
123
+ operator == Operation.ARRAY_OPERATOR
124
+ ) {
125
+ this.processObjectOrArrayOperator(valuesMap, ops, tokens, operator, token);
126
+ } else {
127
+ const token2: ExpressionToken = tokens.pop();
128
+ var v1 = this.getValueFromToken(valuesMap, token2);
129
+ var v2 = this.getValueFromToken(valuesMap, token);
130
+ tokens.push(this.applyBinaryOperation(operator, v1, v2));
131
+ }
132
+ }
133
+
134
+ if (tokens.isEmpty())
135
+ throw new ExecutionException(
136
+ StringFormatter.format('Expression : $ evaluated to null', exp),
137
+ );
138
+
139
+ if (tokens.size() != 1)
140
+ throw new ExecutionException(
141
+ StringFormatter.format('Expression : $ evaluated multiple values $', exp, tokens),
142
+ );
143
+
144
+ const token: ExpressionToken = tokens.get(0);
145
+ if (token instanceof ExpressionTokenValue)
146
+ return (token as ExpressionTokenValue).getElement();
147
+ else if (!(token instanceof Expression)) return this.getValueFromToken(valuesMap, token);
148
+
149
+ throw new ExecutionException(
150
+ StringFormatter.format('Expression : $ evaluated to $', exp, tokens.get(0)),
151
+ );
152
+ }
153
+
154
+ private processObjectOrArrayOperator(
155
+ valuesMap: Map<string, TokenValueExtractor>,
156
+ ops: LinkedList<Operation>,
157
+ tokens: LinkedList<ExpressionToken>,
158
+ operator?: Operation,
159
+ token?: ExpressionToken,
160
+ ): void {
161
+ const objTokens: LinkedList<ExpressionToken> = new LinkedList();
162
+ const objOperations: LinkedList<Operation> = new LinkedList();
163
+
164
+ if (!operator || !token)
165
+ return;
166
+
167
+ do {
168
+ objOperations.push(operator);
169
+ if (token instanceof Expression)
170
+ objTokens.push(
171
+ new ExpressionTokenValue(
172
+ token.toString(),
173
+ this.evaluateExpression(token as Expression, valuesMap),
174
+ ),
175
+ );
176
+ else if (token)
177
+ objTokens.push(token);
178
+ token = tokens.isEmpty() ? undefined : tokens.pop();
179
+ operator = ops.isEmpty() ? undefined : ops.pop();
180
+ } while (operator == Operation.OBJECT_OPERATOR || operator == Operation.ARRAY_OPERATOR);
181
+
182
+ if (token) {
183
+ if (token instanceof Expression)
184
+ objTokens.push(
185
+ new ExpressionTokenValue(
186
+ token.toString(),
187
+ this.evaluateExpression(token as Expression, valuesMap),
188
+ ),
189
+ );
190
+ else objTokens.push(token);
191
+ }
192
+
193
+ if (operator) ops.push(operator);
194
+
195
+ let objToken: ExpressionToken = objTokens.pop();
196
+ let sb: StringBuilder = new StringBuilder(
197
+ objToken instanceof ExpressionTokenValue
198
+ ? (objToken as ExpressionTokenValue).getTokenValue()
199
+ : objToken.toString(),
200
+ );
201
+
202
+ while (!objTokens.isEmpty()) {
203
+ objToken = objTokens.pop();
204
+ operator = objOperations.pop();
205
+ sb.append(operator.getOperator()).append(
206
+ objToken instanceof ExpressionTokenValue
207
+ ? (objToken as ExpressionTokenValue).getTokenValue()
208
+ : objToken.toString(),
209
+ );
210
+ if (operator == Operation.ARRAY_OPERATOR) sb.append(']');
211
+ }
212
+
213
+ let str: string = sb.toString();
214
+ let key: string = str.substring(0, str.indexOf('.') + 1);
215
+ if (key.length > 2 && valuesMap.has(key))
216
+ tokens.push(new ExpressionTokenValue(str, this.getValue(str, valuesMap)));
217
+ else {
218
+ let v: any = undefined;
219
+ try {
220
+ v = LiteralTokenValueExtractor.INSTANCE.getValue(str);
221
+ } catch (err) {
222
+ v = str;
223
+ }
224
+ tokens.push(new ExpressionTokenValue(str, v));
225
+ }
226
+ }
227
+
228
+ private applyBinaryOperation(operator: Operation, v1: any, v2: any): ExpressionToken {
229
+ let typv1: string = typeof v1;
230
+ let typv2: string = typeof v2;
231
+
232
+ if (typv1 === 'object' || typv2 === 'object' || Array.isArray(v1) || Array.isArray(v2))
233
+ throw new ExpressionEvaluationException(
234
+ this.expression,
235
+ StringFormatter.format(
236
+ 'Cannot evaluate expression $ $ $',
237
+ v1,
238
+ operator.getOperator(),
239
+ v2,
240
+ ),
241
+ );
242
+
243
+ let op: BinaryOperator | undefined = ExpressionEvaluator.BINARY_OPERATORS_MAP.get(operator);
244
+
245
+ if (!op)
246
+ throw new ExpressionEvaluationException(
247
+ this.expression,
248
+ StringFormatter.format(
249
+ 'No operator found to evaluate $ $ $',
250
+ v1,
251
+ operator.getOperator(),
252
+ v2,
253
+ ),
254
+ );
255
+
256
+ return new ExpressionTokenValue(operator.toString(), op.apply(v1, v2));
257
+ }
258
+
259
+ private applyUnaryOperation(operator: Operation, value: any): ExpressionToken {
260
+ let typv: string = typeof value;
261
+
262
+ if (typv === 'object' || Array.isArray(value))
263
+ throw new ExpressionEvaluationException(
264
+ this.expression,
265
+ StringFormatter.format(
266
+ 'The operator $ cannot be applied to $',
267
+ operator.getOperator(),
268
+ value,
269
+ ),
270
+ );
271
+
272
+ let op: UnaryOperator | undefined = ExpressionEvaluator.UNARY_OPERATORS_MAP.get(operator);
273
+
274
+ if (!op)
275
+ throw new ExpressionEvaluationException(
276
+ this.expression,
277
+ StringFormatter.format(
278
+ 'No Unary operator $ is found to apply on $',
279
+ operator.getOperator(),
280
+ value,
281
+ ),
282
+ );
283
+
284
+ return new ExpressionTokenValue(operator.toString(), op.apply(value));
285
+ }
286
+
287
+ private getValueFromToken(
288
+ valuesMap: Map<string, TokenValueExtractor>,
289
+ token: ExpressionToken,
290
+ ): any {
291
+ if (token instanceof Expression) {
292
+ return this.evaluateExpression(token as Expression, valuesMap);
293
+ } else if (token instanceof ExpressionTokenValue) {
294
+ return (token as ExpressionTokenValue).getElement();
295
+ }
296
+ return this.getValue(token.getExpression(), valuesMap);
297
+ }
298
+
299
+ private getValue(path: string, valuesMap: Map<string, TokenValueExtractor>): any {
300
+ if (path.length <= 5) return LiteralTokenValueExtractor.INSTANCE.getValue(path);
301
+
302
+ const pathPrefix: string = path.substring(0, path.indexOf('.') + 1);
303
+ return (valuesMap.get(pathPrefix) ?? LiteralTokenValueExtractor.INSTANCE).getValue(path);
304
+ }
305
+ }
@@ -0,0 +1,15 @@
1
+ export class ExpressionToken {
2
+ expression: string;
3
+
4
+ public constructor(expression: string) {
5
+ this.expression = expression;
6
+ }
7
+
8
+ public getExpression(): string {
9
+ return this.expression;
10
+ }
11
+
12
+ public toString(): string {
13
+ return this.expression;
14
+ }
15
+ }
@@ -0,0 +1,23 @@
1
+ import { StringFormatter } from '../../util/string/StringFormatter';
2
+ import { ExpressionToken } from './ExpressionToken';
3
+
4
+ export class ExpressionTokenValue extends ExpressionToken {
5
+ private element: any;
6
+
7
+ public constructor(expression: string, element: any) {
8
+ super(expression);
9
+ this.element = element;
10
+ }
11
+
12
+ public getTokenValue(): any {
13
+ return this.element;
14
+ }
15
+
16
+ public getElement(): any {
17
+ return this.element;
18
+ }
19
+
20
+ public toString(): string {
21
+ return StringFormatter.format('$: $', this.expression, this.element);
22
+ }
23
+ }
@@ -0,0 +1,190 @@
1
+ export class Operation {
2
+ public static readonly MULTIPLICATION: Operation = new Operation('*');
3
+ public static readonly DIVISION: Operation = new Operation('/');
4
+ public static readonly INTEGER_DIVISION: Operation = new Operation('//');
5
+ public static readonly MOD: Operation = new Operation('%');
6
+ public static readonly ADDITION: Operation = new Operation('+');
7
+ public static readonly SUBTRACTION: Operation = new Operation('-');
8
+
9
+ public static readonly NOT: Operation = new Operation('not');
10
+ public static readonly AND: Operation = new Operation('and');
11
+ public static readonly OR: Operation = new Operation('or');
12
+ public static readonly LESS_THAN: Operation = new Operation('<');
13
+ public static readonly LESS_THAN_EQUAL: Operation = new Operation('<=');
14
+ public static readonly GREATER_THAN: Operation = new Operation('>');
15
+ public static readonly GREATER_THAN_EQUAL: Operation = new Operation('>=');
16
+ public static readonly EQUAL: Operation = new Operation('=');
17
+ public static readonly NOT_EQUAL: Operation = new Operation('!=');
18
+
19
+ public static readonly BITWISE_AND: Operation = new Operation('&');
20
+ public static readonly BITWISE_OR: Operation = new Operation('|');
21
+ public static readonly BITWISE_XOR: Operation = new Operation('^');
22
+ public static readonly BITWISE_COMPLEMENT: Operation = new Operation('~');
23
+ public static readonly BITWISE_LEFT_SHIFT: Operation = new Operation('<<');
24
+ public static readonly BITWISE_RIGHT_SHIFT: Operation = new Operation('>>');
25
+ public static readonly BITWISE_UNSIGNED_RIGHT_SHIFT: Operation = new Operation('>>>');
26
+
27
+ public static readonly UNARY_PLUS: Operation = new Operation('UN: +', '+');
28
+ public static readonly UNARY_MINUS: Operation = new Operation('UN: -', '-');
29
+ public static readonly UNARY_LOGICAL_NOT: Operation = new Operation('UN: not', 'not');
30
+ public static readonly UNARY_BITWISE_COMPLEMENT: Operation = new Operation('UN: ~', '~');
31
+
32
+ public static readonly ARRAY_OPERATOR: Operation = new Operation('[');
33
+ public static readonly OBJECT_OPERATOR: Operation = new Operation('.');
34
+
35
+ private static readonly VALUE_OF: Map<string, Operation> = new Map([
36
+ ['MULTIPLICATION', Operation.MULTIPLICATION],
37
+ ['DIVISION', Operation.DIVISION],
38
+ ['INTEGER_DIVISON', Operation.INTEGER_DIVISION],
39
+ ['MOD', Operation.MOD],
40
+ ['ADDITION', Operation.ADDITION],
41
+ ['SUBTRACTION', Operation.SUBTRACTION],
42
+ ['NOT', Operation.NOT],
43
+ ['AND', Operation.AND],
44
+ ['OR', Operation.OR],
45
+ ['LESS_THAN', Operation.LESS_THAN],
46
+ ['LESS_THAN_EQUAL', Operation.LESS_THAN_EQUAL],
47
+ ['GREATER_THAN', Operation.GREATER_THAN],
48
+ ['GREATER_THAN_EQUAL', Operation.GREATER_THAN_EQUAL],
49
+ ['EQUAL', Operation.EQUAL],
50
+ ['NOT_EQUAL', Operation.NOT_EQUAL],
51
+ ['BITWISE_AND', Operation.BITWISE_AND],
52
+ ['BITWISE_OR', Operation.BITWISE_OR],
53
+ ['BITWISE_XOR', Operation.BITWISE_XOR],
54
+ ['BITWISE_COMPLEMENT', Operation.BITWISE_COMPLEMENT],
55
+ ['BITWISE_LEFT_SHIFT', Operation.BITWISE_LEFT_SHIFT],
56
+ ['BITWISE_RIGHT_SHIFT', Operation.BITWISE_RIGHT_SHIFT],
57
+ ['BITWISE_UNSIGNED_RIGHT_SHIFT', Operation.BITWISE_UNSIGNED_RIGHT_SHIFT],
58
+ ['UNARY_PLUS', Operation.UNARY_PLUS],
59
+ ['UNARY_MINUS', Operation.UNARY_MINUS],
60
+ ['UNARY_LOGICAL_NOT', Operation.UNARY_LOGICAL_NOT],
61
+ ['UNARY_BITWISE_COMPLEMENT', Operation.UNARY_BITWISE_COMPLEMENT],
62
+ ['ARRAY_OPERATOR', Operation.ARRAY_OPERATOR],
63
+ ['OBJECT_OPERATOR', Operation.OBJECT_OPERATOR],
64
+ ]);
65
+
66
+ public static readonly UNARY_OPERATORS: Set<Operation> = new Set([
67
+ Operation.ADDITION,
68
+ Operation.SUBTRACTION,
69
+ Operation.NOT,
70
+ Operation.BITWISE_COMPLEMENT,
71
+ Operation.UNARY_PLUS,
72
+ Operation.UNARY_MINUS,
73
+ Operation.UNARY_LOGICAL_NOT,
74
+ Operation.UNARY_BITWISE_COMPLEMENT,
75
+ ]);
76
+
77
+ public static readonly ARITHMETIC_OPERATORS: Set<Operation> = new Set([
78
+ Operation.MULTIPLICATION,
79
+ Operation.DIVISION,
80
+ Operation.INTEGER_DIVISION,
81
+ Operation.MOD,
82
+ Operation.ADDITION,
83
+ Operation.SUBTRACTION,
84
+ ]);
85
+
86
+ public static readonly LOGICAL_OPERATORS: Set<Operation> = new Set([
87
+ Operation.NOT,
88
+ Operation.AND,
89
+ Operation.OR,
90
+ Operation.LESS_THAN,
91
+ Operation.LESS_THAN_EQUAL,
92
+ Operation.GREATER_THAN,
93
+ Operation.GREATER_THAN_EQUAL,
94
+ Operation.EQUAL,
95
+ Operation.NOT_EQUAL,
96
+ ]);
97
+
98
+ public static readonly BITWISE_OPERATORS: Set<Operation> = new Set([
99
+ Operation.BITWISE_AND,
100
+ Operation.BITWISE_COMPLEMENT,
101
+ Operation.BITWISE_LEFT_SHIFT,
102
+ Operation.BITWISE_OR,
103
+ Operation.BITWISE_RIGHT_SHIFT,
104
+ Operation.BITWISE_UNSIGNED_RIGHT_SHIFT,
105
+ Operation.BITWISE_XOR,
106
+ ]);
107
+
108
+ public static readonly OPERATOR_PRIORITY: Map<Operation, number> = new Map([
109
+ [Operation.UNARY_PLUS, 1],
110
+ [Operation.UNARY_MINUS, 1],
111
+ [Operation.UNARY_LOGICAL_NOT, 1],
112
+ [Operation.UNARY_BITWISE_COMPLEMENT, 1],
113
+ [Operation.ARRAY_OPERATOR, 1],
114
+ [Operation.OBJECT_OPERATOR, 1],
115
+ [Operation.MULTIPLICATION, 2],
116
+ [Operation.DIVISION, 2],
117
+ [Operation.INTEGER_DIVISION, 2],
118
+ [Operation.MOD, 2],
119
+ [Operation.ADDITION, 3],
120
+ [Operation.SUBTRACTION, 3],
121
+ [Operation.BITWISE_LEFT_SHIFT, 4],
122
+ [Operation.BITWISE_RIGHT_SHIFT, 4],
123
+ [Operation.BITWISE_UNSIGNED_RIGHT_SHIFT, 4],
124
+ [Operation.LESS_THAN, 5],
125
+ [Operation.LESS_THAN_EQUAL, 5],
126
+ [Operation.GREATER_THAN, 5],
127
+ [Operation.GREATER_THAN_EQUAL, 5],
128
+ [Operation.EQUAL, 6],
129
+ [Operation.NOT_EQUAL, 6],
130
+ [Operation.BITWISE_AND, 7],
131
+ [Operation.BITWISE_XOR, 8],
132
+ [Operation.BITWISE_OR, 9],
133
+ [Operation.AND, 10],
134
+ [Operation.OR, 11],
135
+ ]);
136
+
137
+ public static readonly OPERATORS: Set<string> = new Set(
138
+ [
139
+ ...Array.from(Operation.ARITHMETIC_OPERATORS),
140
+ ...Array.from(Operation.LOGICAL_OPERATORS),
141
+ ...Array.from(Operation.BITWISE_OPERATORS),
142
+ Operation.ARRAY_OPERATOR,
143
+ Operation.OBJECT_OPERATOR,
144
+ ].map((e) => e.getOperator()),
145
+ );
146
+
147
+ public static readonly OPERATION_VALUE_OF: Map<string, Operation> = new Map(
148
+ Array.from(Operation.VALUE_OF.entries()).map(([_, o]) => [o.getOperator(), o]),
149
+ );
150
+
151
+ public static readonly UNARY_MAP: Map<Operation, Operation> = new Map([
152
+ [Operation.ADDITION, Operation.UNARY_PLUS],
153
+ [Operation.SUBTRACTION, Operation.UNARY_MINUS],
154
+ [Operation.NOT, Operation.UNARY_LOGICAL_NOT],
155
+ [Operation.BITWISE_COMPLEMENT, Operation.UNARY_BITWISE_COMPLEMENT],
156
+ [Operation.UNARY_PLUS, Operation.UNARY_PLUS],
157
+ [Operation.UNARY_MINUS, Operation.UNARY_MINUS],
158
+ [Operation.UNARY_LOGICAL_NOT, Operation.UNARY_LOGICAL_NOT],
159
+ [Operation.UNARY_BITWISE_COMPLEMENT, Operation.UNARY_BITWISE_COMPLEMENT],
160
+ ]);
161
+
162
+ public static readonly BIGGEST_OPERATOR_SIZE: number = Array.from(Operation.VALUE_OF.values())
163
+ .map((e) => e.getOperator())
164
+ .filter((e) => !e.startsWith('UN: '))
165
+ .map((e) => e.length)
166
+ .reduce((a, c) => (a > c ? a : c), 0);
167
+
168
+ private operator: string;
169
+ private operatorName: string;
170
+ public constructor(operator: string, operatorName?: string) {
171
+ this.operator = operator;
172
+ this.operatorName = operatorName ?? operator;
173
+ }
174
+
175
+ public getOperator(): string {
176
+ return this.operator;
177
+ }
178
+
179
+ public getOperatorName(): string {
180
+ return this.operatorName;
181
+ }
182
+
183
+ public valueOf(str: string): Operation | undefined {
184
+ return Operation.VALUE_OF.get(str);
185
+ }
186
+
187
+ public toString(): string {
188
+ return this.operator;
189
+ }
190
+ }
@@ -0,0 +1,15 @@
1
+ import { StringFormatter } from '../../../util/string/StringFormatter';
2
+
3
+ export class ExpressionEvaluationException extends Error {
4
+ private cause?: Error;
5
+
6
+ constructor(expression: string, message: string, err?: Error) {
7
+ super(StringFormatter.format('$ : $', expression, message));
8
+
9
+ this.cause = err;
10
+ }
11
+
12
+ public getCause(): Error | undefined {
13
+ return this.cause;
14
+ }
15
+ }
@@ -0,0 +1,9 @@
1
+ import { Operation } from '../../Operation';
2
+ import { BinaryOperator } from './BinaryOperator';
3
+
4
+ export class ArithmeticAdditionOperator extends BinaryOperator {
5
+ public apply(t: any, u: any): any {
6
+ this.nullCheck(t, u, Operation.ADDITION);
7
+ return t + u;
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ import { Operation } from '../../Operation';
2
+ import { BinaryOperator } from './BinaryOperator';
3
+
4
+ export class ArithmeticDivisionOperator extends BinaryOperator {
5
+ public apply(t: any, u: any): any {
6
+ this.nullCheck(t, u, Operation.DIVISION);
7
+ return t / u;
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ import { Operation } from '../../Operation';
2
+ import { BinaryOperator } from './BinaryOperator';
3
+
4
+ export class ArithmeticIntegerDivisionOperator extends BinaryOperator {
5
+ public apply(t: any, u: any): any {
6
+ this.nullCheck(t, u, Operation.DIVISION);
7
+ return Math.floor(t / u);
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ import { Operation } from '../../Operation';
2
+ import { BinaryOperator } from './BinaryOperator';
3
+
4
+ export class ArithmeticModulusOperator extends BinaryOperator {
5
+ public apply(t: any, u: any): any {
6
+ this.nullCheck(t, u, Operation.MOD);
7
+ return t % u;
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ import { Operation } from '../../Operation';
2
+ import { BinaryOperator } from './BinaryOperator';
3
+
4
+ export class ArithmeticMultiplicationOperator extends BinaryOperator {
5
+ public apply(t: any, u: any): any {
6
+ this.nullCheck(t, u, Operation.MULTIPLICATION);
7
+ return t * u;
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ import { Operation } from '../../Operation';
2
+ import { BinaryOperator } from './BinaryOperator';
3
+
4
+ export class ArithmeticSubtractionOperator extends BinaryOperator {
5
+ public apply(t: any, u: any): any {
6
+ this.nullCheck(t, u, Operation.SUBTRACTION);
7
+ return t - u;
8
+ }
9
+ }
@@ -0,0 +1,31 @@
1
+ import { ExecutionException } from '../../../../exception/ExecutionException';
2
+ import { StringFormatter } from '../../../../util/string/StringFormatter';
3
+ import { BinaryOperator } from './BinaryOperator';
4
+
5
+ export class ArrayOperator extends BinaryOperator {
6
+ public apply(t: any, u: any): any {
7
+ if (!t) {
8
+ throw new ExecutionException('Cannot apply array operator on a null value');
9
+ }
10
+
11
+ if (!u) {
12
+ throw new ExecutionException('Cannot retrive null index value');
13
+ }
14
+
15
+ if (!Array.isArray(t) && typeof t != 'string') {
16
+ throw new ExecutionException(
17
+ StringFormatter.format('Cannot retrieve value from a primitive value $', t),
18
+ );
19
+ }
20
+ if (u >= t.length)
21
+ throw new ExecutionException(
22
+ StringFormatter.format(
23
+ 'Cannot retrieve index $ from the array of length $',
24
+ u,
25
+ t.length,
26
+ ),
27
+ );
28
+
29
+ return t[u];
30
+ }
31
+ }
@@ -0,0 +1,15 @@
1
+ import { ExecutionException } from '../../../../exception/ExecutionException';
2
+ import { isNullValue } from '../../../../util/NullCheck';
3
+ import { StringFormatter } from '../../../../util/string/StringFormatter';
4
+ import { Operation } from '../../Operation';
5
+
6
+ export abstract class BinaryOperator {
7
+ public abstract apply(t: any, u: any): any;
8
+
9
+ public nullCheck(e1: any, e2: any, op: Operation): void {
10
+ if (isNullValue(e1) || isNullValue(e2))
11
+ throw new ExecutionException(
12
+ StringFormatter.format('$ cannot be applied to a null value', op.getOperatorName()),
13
+ );
14
+ }
15
+ }
@@ -0,0 +1,9 @@
1
+ import { Operation } from '../../Operation';
2
+ import { BinaryOperator } from './BinaryOperator';
3
+
4
+ export class BitwiseAndOperator extends BinaryOperator {
5
+ public apply(t: any, u: any): any {
6
+ this.nullCheck(t, u, Operation.BITWISE_AND);
7
+ return t & u;
8
+ }
9
+ }