1010import java .util .concurrent .ConcurrentHashMap ;
1111import java .util .stream .Collectors ;
1212
13- import static io .javaoperatorsdk .operator .ControllerUtils .CONTROLLERS_RESOURCE_PATH ;
14-
15- class ControllersResourceWriter {
13+ class AccumulativeMappingWriter {
1614 private Map <String , String > mappings = new ConcurrentHashMap <>();
15+ private final String resourcePath ;
1716 private final ProcessingEnvironment processingEnvironment ;
1817
19- public ControllersResourceWriter (ProcessingEnvironment processingEnvironment ) {
18+ public AccumulativeMappingWriter (String resourcePath , ProcessingEnvironment processingEnvironment ) {
19+ this .resourcePath = resourcePath ;
2020 this .processingEnvironment = processingEnvironment ;
2121 }
2222
23- public ControllersResourceWriter loadExistingMappings () {
23+ public AccumulativeMappingWriter loadExistingMappings () {
2424 try {
2525 final var readonlyResource = processingEnvironment
2626 .getFiler ()
27- .getResource (StandardLocation .CLASS_OUTPUT , "" , CONTROLLERS_RESOURCE_PATH );
27+ .getResource (StandardLocation .CLASS_OUTPUT , "" , resourcePath );
2828
2929 final var bufferedReader = new BufferedReader (new InputStreamReader (readonlyResource .openInputStream ()));
3030 final var existingLines = bufferedReader
@@ -37,8 +37,8 @@ public ControllersResourceWriter loadExistingMappings() {
3737 return this ;
3838 }
3939
40- public ControllersResourceWriter add (String controllerClassName , String customResourceTypeName ) {
41- this .mappings .put (controllerClassName , customResourceTypeName );
40+ public AccumulativeMappingWriter add (String key , String value ) {
41+ this .mappings .put (key , value );
4242 return this ;
4343 }
4444
@@ -47,7 +47,7 @@ public void flush() {
4747 try {
4848 final var resource = processingEnvironment
4949 .getFiler ()
50- .createResource (StandardLocation .CLASS_OUTPUT , "" , CONTROLLERS_RESOURCE_PATH );
50+ .createResource (StandardLocation .CLASS_OUTPUT , "" , resourcePath );
5151 printWriter = new PrintWriter (resource .openOutputStream ());
5252
5353
0 commit comments