posted 7 years ago
Hello Ranchers!
I've ran into a bit of a block where I dont want to solve a problem by chaining 10 or so of myList.add(first).add(second)...add(thirteenth); into a method, or even write them out on separate lines. I haven't been able to come up with any useful or not complicated ideas to solve this, so here is my enum:
The whole thing is because I store all of these in the same database table. For various complicated reasons, this has to stay like this. Thus, to separate the special work times that a vehicle has (in service, in rent, out of service) and the special work times that a person/user has (holiday, sickleave etc) I need these two static methods to be able to conviniently retrieve them.
My question is, how to do the methods more handsomely? Adding the enum members one-by-one is pretty unfriendly for future expansion of the enum.
My thought was to somehow make them into a loop, but I couldn't find an enum attribute that would let me to. Maybe make an individual ID for each, in their constructor? But then I would need an instance of each?
Making a private static int counter burnt in it would be risky of mistakes, too. I'm out of ideas!
Is there a common way to do this that I have overlooked?
I looked on stack overflow but couldn't find an example for this, please rescue my newbie soul!
Best regards and thank you for your time, Dóri