@@ -585,8 +585,8 @@ public void execute() throws MojoExecutionException {
585585 configurator = new CodegenConfigurator ();
586586 } else {
587587 // retrieve mandatory fields from the configurationFile if not defined in the pom.xml
588- this .generatorName = fromConfigurator (configurator , "generatorName" , String . class , generatorName );
589- this .inputSpec = fromConfigurator (configurator , "inputSpec" , String . class , inputSpec );
588+ this .generatorName = fromConfigurator (configurator . getGeneratorName (), generatorName );
589+ this .inputSpec = fromConfigurator (configurator . getInputSpec () , inputSpec );
590590 }
591591
592592 if (StringUtils .isBlank (inputSpec ) && StringUtils .isBlank (inputSpecRootDirectory )) {
@@ -1051,27 +1051,16 @@ public void execute() throws MojoExecutionException {
10511051 }
10521052
10531053 /**
1054- * Access private fields of the CodegenConfigurator class.
1054+ * Use the configurator value is not defined in the pom.xml
10551055 *
1056- * @param configurator the CodegenConfigurator
1057- * @param fieldName name of the field
1058- * @param clazz type of the field
1059- * @param defaultValue default if configuration.fieldName is null
1060- * @return the value of configuration.fieldName if defaultValue is null
1056+ * @param defaultValue default value taking precedence
10611057 */
1062- private <T > T fromConfigurator (CodegenConfigurator configurator , String fieldName , Class < T > clazz , T defaultValue ) {
1058+ private <T > T fromConfigurator (T value , T defaultValue ) {
10631059 if (defaultValue != null ) {
10641060 // keep backward compatibilty, the value in the pom.xml has precedence over the value in the config file.
10651061 return defaultValue ;
10661062 }
1067- try {
1068- Field field = CodegenConfigurator .class .getDeclaredField (fieldName );
1069- field .setAccessible (true );
1070- T value = (T )field .get (configurator );
1071- return value == null ? defaultValue : value ;
1072- } catch (Exception e ) {
1073- throw new RuntimeException ("Failed to read " + fieldName + " from configuration file." , e );
1074- }
1063+ return value ;
10751064 }
10761065
10771066 /**
0 commit comments