package com.guidewire.rating.flow.domain.util uses gw.api.system.PCConfigParameters uses gw.validation.PCValidationContext @SuppressWarnings("HiddenPackageReference") final class CalcRoutineCodeGeneratorFactory { public enum CodegenStrategy { SIMPLE("Simple, single method", CalcRoutineSimpleCodeGenerator#construct(CalcRoutineDefinition, List, PCValidationContext, boolean, boolean)), CHAIN("Chain of methods", CalcRoutineMethodChainCodeGenerator#construct(CalcRoutineDefinition, List, PCValidationContext, boolean, boolean)), SEQUENCE("Sequence of methods", CalcRoutineMethodSequenceCodeGenerator#construct(CalcRoutineDefinition, List, PCValidationContext, boolean, boolean)) public final var Description: String public final var CodegenCreator: block(CalcRoutineDefinition, List, PCValidationContext, boolean, boolean): CalcRoutineCodeGenerator private construct(desc: String, creator: block(CalcRoutineDefinition, List, PCValidationContext, boolean, boolean): CalcRoutineCodeGenerator) { Description = desc CodegenCreator = creator } } static property get DefaultCodegenStrategy(): CodegenStrategy { return CodegenStrategy.valueOf(PCConfigParameters.RateRoutineCodegenStrategy.Value) } private construct() { } /** * Gets a code generator that implements the specified code generation strategy. * * @param definition the rate routine definition * @param orderedSteps rate routine steps, in order * @param validationContext for recording errors. May be null * @param worksheets whether worksheet capture is on or off * @param strategy {@link CodegenStrategy code generation strategy}. If null then the configured * default code generation strategy is chosen. * * @return a code generator for the specified rate routine definition that implements the specified strategy * * @see PCConfigParameters#RateRoutineCodegenStrategy */ static function get(definition : CalcRoutineDefinition, orderedSteps : List, validationContext : PCValidationContext, worksheets : boolean, useUniquePkgNameSuffix: boolean, strategy : CodegenStrategy = null) : CalcRoutineCodeGenerator { if (strategy == null) { /** * We tried: small = SIMPLE, large = default (CHAIN | SEQUENCE) * That leads to picking SIMPLE far too often and since SIMPLE adds lambdas for all IFs, it results in far more * classes than desired. */ strategy = DefaultCodegenStrategy } return strategy.CodegenCreator(definition, orderedSteps, validationContext, worksheets, useUniquePkgNameSuffix) } }