I'm trying to create a lot of objects, but using new ObjectName(...) over and over is not what I'm looking for.
new Obj("String", 0, true);
new Obj("Diff", 9, true);
new Obj("Changed", 2, false);
...
I would like something similar to:
massCreateObj({
{"String", 0, true },
{"Diff", 9, true },
{"Changed", 2, false}
...
});
I want to do this because it will be easier to manage for multiple objects, such as:
massCreateObjs({
"Obj" => {
{"str", 0, false},
{"sss", 1, true}
},
"Obj2" => {
{false, "different"},
{true, "diff"}
}
});
Otherwise, I would have to flatten this:
new Obj("str", 0, false);
new Obj("sss", 1, true);
new Obj2(false, "different");
new Obj2(true, "diff");
This is just simply not scalable. With an array, I can easily see which objects are being created, and there isn't text repeated (the new object name).
Is there a way I can use Hashmaps, Arrays, or tuples to accomplish this? (Open to other solutions too)
I've taken a look at hashmaps but it's essentially only a K->V setup.
I've also looked at wrappers, but then, it's back to where I've started. If I create a class/interface, I still need to use new class name or whatever, which is what I'm avoiding in the first place.