I'm relatively new to Java and I'm trying to refactor some code I wrote to make it more generic.
I currently have several classes that are basically exactly the same except they each have a different enum. For instance, I have an A class that stores values for AData1, AData2, AData3. I also have a B class that stores values for BData1 and BData2. I have an enum of AData1, AData2, AData3 and another enum of BData1 and BData2.
The classes have essentially the same methods, but the only difference is their enum.
I was hoping to create a generic class and then simply pass in the enum to a constructor on an instance. I'm thinking I can use an EnumMap to store the values I need. I can't figure out how to pass in an entire enum to a function. I can pass in one value from the enum, but not the entire thing. Any ideas?
I currently have several classes that are basically exactly the same except they each have a different enum. For instance, I have an A class that stores values for AData1, AData2, AData3. I also have a B class that stores values for BData1 and BData2. I have an enum of AData1, AData2, AData3 and another enum of BData1 and BData2.
The classes have essentially the same methods, but the only difference is their enum.
I was hoping to create a generic class and then simply pass in the enum to a constructor on an instance. I'm thinking I can use an EnumMap to store the values I need. I can't figure out how to pass in an entire enum to a function. I can pass in one value from the enum, but not the entire thing. Any ideas?