Design Pattern for mapping generic class type to implementation
Hey all,
I'm working on an executor service that maps an executor record of a generic type to an executor that can handle performing operations on that type. Currently, I'm receiving errors on a type conversion in my executor methods for being unable to convert a type and I am not sure how to fix it in my design. I believe this design pattern is similar to mapping a command to a handler, but I am just having trouble implementing it. If you can give me feedback on how to my design or how to do it properly it would help a ton, I have been stuck on this for a bit trying different things.
To start off, I have a ExecutorService thats job is to take an executor record and map it to an executor and return the results. Each executor has it's own implementation with a catch all "object" executor as default. This requires a few components:
I'm working on an executor service that maps an executor record of a generic type to an executor that can handle performing operations on that type. Currently, I'm receiving errors on a type conversion in my executor methods for being unable to convert a type and I am not sure how to fix it in my design. I believe this design pattern is similar to mapping a command to a handler, but I am just having trouble implementing it. If you can give me feedback on how to my design or how to do it properly it would help a ton, I have been stuck on this for a bit trying different things.
To start off, I have a ExecutorService thats job is to take an executor record and map it to an executor and return the results. Each executor has it's own implementation with a catch all "object" executor as default. This requires a few components:
- ExecutorService, which is my service that my controller uses.
- ExecutorManager, which is my executor manager that registers all executors from DI and allows the executor service to get a executor by key and pass the executor record to that executor to perform an operation.
- Executor, which is a handler for performing basic crud operations on executor records of a specific type.
- ExecutorRecord, which is class for storing generic types of data while containing basic information about that data that is common across executors.
- ExampleRepository, which is a repository that ExecutorRecords will get from DI for what repository to call for basic CRUD operations.