What I am trying to build has a 16 page list of requirements. So I cannot post code that builds what I am actually putting together. So I tried to provide the skeleton of a simpler application.
What I am really interested in is not implementing the simple example. I am interested in trying to sort out how to define collections of objects in a way that makes sense.
There are several layers in the application-
A set of basic objects that expose methods to get their value through their interface.
An object that takes lists of each of these objects and maintains state information, such as whether the basic objects currently held can meet certain conditions, and whether specific items in the list are considered in use.
An application that takes a list of the latter objects and sets their states, the order in which the objects are examined depending on a set of keys, one key being associated with each list. Though key may be the wrong
word, since lists may or may not have the same key value.
I am trying to get a good paradigm for creating the lists of objects and associating with them a key.
There are many methods for creating these lists. Each requires a different set of parameters. The lists may be created on the fly while the program is running or may be read from a file when the program starts.
I suspect the set of keys (which represent the way the list is created- not a specific instance of a list) will change over time.
Right now, the keys are defined as enums in the class that maintains the state information, which also has a custom comparator to make it easy to sort a list of these objects. That allows me to examine them in the correct order.
Right now, I just have a lot of separate classes that make the different kinds of lists. When I create an instance of the object that maintains the state of the lists, I give it the keys and I give it the lists. It's the method instantiating this class that maps the key to the list and so its up to the programmer to enter this correctly.
It seems like there should be a better way to handle the list creation/key mapping. I am getting hung up as to where the enums should actually be defined and how to create some encompassing class that can build lists and associate keys with them because the arguments to the methods for making lists are different for every list (though in the end, the created lists are all ArrayList<Item>). If the lists were never created dynamically and never shared keys, I would just have a switch on the key and hard code the arguments. Its unclear how to handle the case where I need to pass arguments and might reuse the key.