package gw.rating.worksheet uses gw.lang.reflect.IType uses gw.lang.reflect.TypeSystem uses gw.lang.reflect.java.JavaTypes uses gw.rating.RateRoutineExecutionOperator uses gw.rating.RateRoutineExecutionTermWrapper uses gw.rating.worksheet.WorksheetLogger.WorksheetOperationFrame uses gw.rating.worksheet.WorksheetLogger.WorksheetVoidFunctionFrame uses gw.rating.worksheet.domain.WorksheetArgument uses gw.rating.worksheet.domain.WorksheetConstant uses gw.rating.worksheet.domain.WorksheetFunction uses gw.rating.worksheet.domain.WorksheetInstanceSubroutine uses gw.rating.worksheet.domain.WorksheetNegation uses gw.rating.worksheet.domain.WorksheetNewObject uses gw.rating.worksheet.domain.WorksheetObjectProperty uses gw.rating.worksheet.domain.WorksheetVariable /** * Captures term values along with their preceding operators and surrounding parentheses */ class WorksheetTermWrapper implements RateRoutineExecutionTermWrapper { public final var Operator : RateRoutineExecutionOperator public var WorksheetLogger : WorksheetLogger protected construct(logger : WorksheetLogger, op : RateRoutineExecutionOperator) { WorksheetLogger = logger Operator = op } /** * Captures a constant value * @param value The value * @return the value of the constant * */ override reified function co(value : T) : T{ return co(value, 0, 0) } /** * Captures a constant value along with its surrounding parentheses * @param value The constant value * @param leftParens the number of parentheses to the left * @param rightParens the number of parentheses to the right * @return the value of the constant * */ override reified function co(value : T, leftParens : int, rightParens : int) : T{ var operand = new WorksheetConstant() { :Operator = Operator, :LeftParentheses = leftParens, :RightParentheses = rightParens } return WorksheetLogger.pushExecPop(operand, \ -> value) } /** * Captures a variable * @param name Variable name * @param value Variable value * @return the variable value */ override reified function vr(name : String, value : T) : T{ return vr(name, null, value, 0, 0, null) } /** * Captures a variable * @param name Variable name * @param value Variable value * @param type Arbitrary string value; may be useful as a rendering hint * @return the variable value */ override reified function vr(name : String, type : String, value : T) : T{ return vr(name, type, value, 0, 0, null) } /** * Captures a variable along with is surrounding parentheses * @param name Variable name * @param value Variable value * @param leftParens the number of parentheses to the left * @param rightParens the number of parentheses to the right * @return the variable value */ override reified function vr(name : String, value : T, leftParens : int, rightParens : int) : T{ return vr(name, null, value, leftParens, rightParens, null) } /** * Captures a variable along with is surrounding parentheses * @param name Variable name * @param value Variable value * @param type Arbitrary string value; may be useful as a rendering hint * @param leftParens the number of parentheses to the left * @param rightParens the number of parentheses to the right * @return the variable value */ override reified function vr(name : String, type : String, value : T, leftParens : int, rightParens : int) : T{ return vr(name, type, value, leftParens, rightParens, null) } /** * Captures a variable along with is surrounding parentheses * @param name Variable name * @param value Variable value * @param type Arbitrary string value; may be useful as a rendering hint * @param leftParens the number of parentheses to the left * @param rightParens the number of parentheses to the right * @param hints an array of hints used for rendering * @return the variable value */ override reified function vr(name : String, type : String, value : T, leftParens : int, rightParens : int, hints : String[]) : T{ var operand = new WorksheetVariable() { :Name = name, :Operator = Operator, :Type = type, :LeftParentheses = leftParens, :RightParentheses = rightParens, :DisplayHints = hints} return WorksheetLogger.pushExecPop(operand, \ -> value) } /** * Captures a value from an object's property getter * @param objectName Object name * @param object Object * @param propertyName Property name * @param value Value * @return the property value * */ override reified function get(objectName: String, object: Object, propertyName: String, value: T) : T{ return get(objectName, object, propertyName, null, value, 0, 0, null) } /** * Captures a value from an object's property getter * @param objectName Object name * @param object Object * @param propertyName Property name * @param type Arbitrary string value; may be useful as a rendering hint * @param value Value * @return the property value * */ override reified function get(objectName: String, object: Object, propertyName: String, type: String, value: T) : T{ return get(objectName, object, propertyName, type, value, 0, 0, null) } /** * Captures a value from an object's property getter * @param objectName Object name * @param object Object * @param propertyName Property name * @param value Value * @param leftParens the number of parentheses to the left * @param rightParens the number of parentheses to the right * @return the property value * */ override reified function get(objectName: String, object: Object, propertyName: String, value: T, leftParens: int, rightParens: int) : T{ return get(objectName, object, propertyName, null, value, leftParens, rightParens, null) } /** * Captures a value from an object's property getter * @param objectName Object name * @param object Object * @param propertyName Property name * @param type Arbitrary string value; may be useful as a rendering hint * @param value Value * @param leftParens the number of parentheses to the left * @param rightParens the number of parentheses to the right * @return the property value * */ override reified function get(objectName: String, object: Object, propertyName: String, type: String, value: T, leftParens: int, rightParens: int) : T{ return get(objectName, object, propertyName, type, value, leftParens, rightParens, null) } /** * Captures a value from an object's property getter * @param objectName Object name * @param object Object * @param propertyName Property name * @param type Arbitrary string value; may be useful as a rendering hint * @param value Value * @param leftParens the number of parentheses to the left * @param rightParens the number of parentheses to the right * @param hints an array of hints used for rendering * @return the property value * */ override reified function get(objectName : String, object : Object, propertyName : String, type : String, value : T, leftParens : int, rightParens : int, hints : String[]) : T { var operand = new WorksheetObjectProperty() { :ObjectName = objectName, :ObjectType = TypeSystem.getFromObject(object).Name, // T.Name? :ObjectValue = object, :PropertyName = propertyName, :Operator = Operator, :Type = type, :LeftParentheses = leftParens, :RightParentheses = rightParens, :DisplayHints = hints} return WorksheetLogger.pushExecPop(operand, \-> value) } /** * Captures a function call * @param clazz Class containing the function * @param functionName Function name * @param code the function call itself * @return the return value of the function call */ @Deprecated("PC9.0.6 Functionality moved to startFn()", "PC9.0.6") override reified function fn(clazz : IType, functionName : String, code : block() : T) : T{ return fn(clazz, functionName, null, code, 0, 0, null) } /** * Captures a function call along with a specified type * @param clazz Class containing the function * @param functionName Function name * @param type Arbitrary string value; may be useful as a rendering hint - ie "Rounding" * @return the return value of the function call */ @Deprecated("PC9.0.6 Functionality moved to startFn()", "PC9.0.6") override reified function fn(clazz : IType, functionName : String, type : String, code : block() : T) : T{ return fn(clazz, functionName, type, code, 0, 0, null) } /** * Captures a function call along with its surrounding parentheses * @param clazz The class containing the function * @param functionName Function name * @param code the function call itself * @param leftParens the number of parentheses to the left * @param rightParens the number of parentheses to the right * @return the return value of the function call */ @Deprecated("PC9.0.6 Functionality moved to startFn()", "PC9.0.6") override reified function fn(clazz : IType, functionName : String, code : block() : T, leftParens : int, rightParens : int) : T{ return fn(clazz, functionName, null, code, leftParens, rightParens, null) } /** * Captures a function call along with its surrounding parentheses * @param clazz The class containing the function * @param functionName Function name * @param type Arbitrary string value; may be useful as a rendering hint * @param code the function call itself * @param leftParens the number of parentheses to the left * @param rightParens the number of parentheses to the right * @return the return value of the function call */ @Deprecated("PC9.0.6 Functionality moved to startFn()", "PC9.0.6") override reified function fn(clazz : IType, functionName : String, type : String, code : block() : T, leftParens : int, rightParens : int) : T{ return fn(clazz, functionName, type, code, leftParens, rightParens, null) } /** * Captures a function call along with its surrounding parentheses * @param clazz The class containing the function * @param functionName Function name * @param type Arbitrary string value; may be useful as a rendering hint * @param code the function call itself * @param leftParens the number of parentheses to the left * @param rightParens the number of parentheses to the right * @param hints an array of hints used for rendering * @return the return value of the function call */ override reified function fn(clazz : IType, functionName : String, type : String, code : block() : T, leftParens : int, rightParens : int, hints : String[]) : T { var operand = new WorksheetFunction() { :ClassName = clazz.DisplayName, :Name = functionName, :Type = type, :Operator = Operator, :LeftParentheses = leftParens, :RightParentheses = rightParens, :DisplayHints = hints} return WorksheetLogger.pushExecPop(operand, code) } /** * Captures a function call (without executing the code for that call) * * Note - must be paired with {@link WorksheetTermWrapper.WorksheetLoggerOperationFrame#calcValue(Object)} * e.g. *
f.startFn(gw.lob.pa.rating.PARatingTestFunctions, "getFirstCoverageForFirstVehicle").calcValue(_gw_lob_pa_rating_PARatingTestFunctions.getFirstCoverageForFirstVehicle(_log.argVar("line", "policyline", _policyline)))
* @param clazz Class containing the function * @param functionName Function name * @return the return value of the function call */ @SuppressWarnings("unused") override reified function startFn(clazz : IType, functionName : String, type: String = null, objectName: String = null, object: T = null, hints: String[] = {}) : WorksheetOperationFrame { var operand = new WorksheetFunction() { :ClassName = clazz.DisplayName, :Name = functionName, :Type = type, :Operator = Operator, :LeftParentheses = 0, :RightParentheses = 0, :ObjectName = objectName, :DisplayHints = hints } if (object != null) { operand.ObjectValue = object operand.ClassName = (typeof object).DisplayName } return new WorksheetOperationFrame(WorksheetLogger.push(operand)) } @SuppressWarnings("unused") override function startArg(name: String): WorksheetOperationFrame { var arg = new WorksheetArgument() { :Name = name } return new WorksheetOperationFrame(WorksheetLogger.push(arg)) } @SuppressWarnings("unused") override function startVfn(clazz : IType, functionName : String) : WorksheetVoidFunctionFrame { var operand = new WorksheetInstanceSubroutine() { :FunctionName = functionName, :Type = JavaTypes.pVOID().Name, :Object = clazz, :ObjectName = null, :ObjectType = (typeof clazz).DisplayName } return new WorksheetVoidFunctionFrame(WorksheetLogger.pushVfn(operand)) } /** * Captures a function call on an object * @param objectName the object's variable name * @param object The object on which the function is invoked * @param functionName Function name * @param code the function call itself * @return the return value of the function call */ @Deprecated("PC9.0.6 Functionality moved to startFn()", "PC9.0.6") override reified function fn(objectName : String, object : Object, functionName : String, code : block() : T) : T{ return fn(objectName, object, functionName, null, code, 0, 0, null) } /** * Captures a function call on an object along with its surrounding parentheses * @param objectName the object's variable name * @param object The object on which the function is invoked * @param functionName Function name * @param type Arbitrary string value; may be useful as a rendering hint * @param code the function call itself * @param leftParens the number of parentheses to the left * @param rightParens the number of parentheses to the right * @return the return value of the function call */ @Deprecated("PC9.0.6 Functionality moved to startFn()", "PC9.0.6") override reified function fn(objectName : String, object : Object, functionName : String, type : String, code : block() : T, leftParens : int, rightParens : int) : T{ return fn(objectName, object, functionName, type, code, leftParens, rightParens, null) } /** * Captures a function call on an object along with its surrounding parentheses * @param objectName the object's variable name * @param object The object on which the function is invoked * @param functionName Function name * @param type Arbitrary string value; may be useful as a rendering hint * @param code the function call itself * @param leftParens the number of parentheses to the left * @param rightParens the number of parentheses to the right * @param hints an array of hints used for rendering * @return the return value of the function call */ @Deprecated("PC9.0.6 Functionality moved to startFn()", "PC9.0.6") override reified function fn(objectName : String, object : Object, functionName : String, type : String, code : block() : T, leftParens : int, rightParens : int, hints : String[]) : T{ var operand = new WorksheetFunction() { :ObjectName = objectName, :ObjectValue = object, :ClassName = (typeof object).DisplayName, :Name = functionName, :Type = type, :Operator = Operator, :LeftParentheses = leftParens, :RightParentheses = rightParens, :DisplayHints = hints} return WorksheetLogger.pushExecPop(operand, code) } /** * Captures a void function call * @param clazz Class containing the function * @param functionName Function name * @param code the function call itself */ @SuppressWarnings("unused") function vfn(clazz : IType, functionName : String, code : block() : void) : void { WorksheetLogger.method(null, clazz, functionName, JavaTypes.pVOID().Name /* "void" */, code) } /** * Log information about a void function call that was already executed. */ @SuppressWarnings("unused") function logVfn(clazz : IType, functionName : String) : void { //call method with a no-op block. The assumption is that the code was already executed. vfn(clazz, functionName, \ -> {}) } /** * Captures a chained function call, such as obj.withParam().withParam() * * @param name of the function call * @param parent the value of the preceding function call * @param code the function call * @return the return value of the function call * */ override reified function chain(name : String, parent : block() : V, code : block(p : V) : T) : T{ var p = parent() var operand = new WorksheetFunction() { :ClassName = TypeSystem.getFromObject(p).Name, :Name = name, :Operator = Dot, :Type = "ChainedFunctionCall"} return WorksheetLogger.pushExecPop(operand, \ -> code(p)) } /** * Captures a logical negation, such as NOT true * * @param the expression being negated * @return the return value of the negated expression * */ override reified function no(code : block() : T) : T{ return no(code, 0, 0) } /** * Captures a logical negation, such as NOT true along with its surrounding parentheses * * @param the expression being negated * @param leftParens the number of parentheses to the left * @param rightParens the number of parentheses to the right * @return the return value of the negated expression * */ override reified function no(code : block() : T, leftParens : int, rightParens : int) : T{ var operand = new WorksheetNegation() { :Operator = Operator, :LeftParentheses = leftParens, :RightParentheses = rightParens} return WorksheetLogger.pushExecPop(operand, code) } /** Captures an object instantiated with the new operator * * @param code * @return new object */ override reified function nnew(code : block() : T) : T{ return nnew(code, 0, 0) } /** Captures an object instantiated with the new operator * * @param code * @param leftParens the number of parentheses to the left * @param rightParens the number of parentheses to the right * @return the new object * */ override reified function nnew(code : block() : T, leftParens : int, rightParens : int) : T{ var operand = new WorksheetNewObject() { :Operator = Operator, :LeftParentheses = leftParens, :RightParentheses = rightParens } return WorksheetLogger.pushExecPop(operand, code) } /** Create a logged rate query * * @param book Ratebook * @param tableCode Table code * @return the logged rate query */ override reified function query(book : RateBook, tableCode : String) : WorksheetLoggedRateQuery { return query(book, tableCode, 0, 0) } /** Create a logged rate query * * @param book Ratebook * @param tableCode Table code * @param leftParens Number of left parenthesis * @param rightParens Number of right parenthesis * @return the logged rate query */ override reified function query(book : RateBook, tableCode : String, leftParens : int, rightParens : int) : WorksheetLoggedRateQuery { return new WorksheetLoggedRateQuery(WorksheetLogger, Operator.Symbol, leftParens, rightParens, book, tableCode) } }