I have one base class
public class BaseInfo { }
Then I have two child class from BaseInfo:
public class FunctionInfo extends BaseInfo {}
public class ComponentInfo extends BaseInfo {}
Now In rest layer there is one method using which I can get the collection of those child objects similar to below
Map<String, List<ComponentInfo>> allCompInfo = componentLayer.findById(Id, true);
Map<String, List<FunctionInfo>> allFunctionInfo = functionLayer.findById(Id);
Here In my next method I have to send the allCompInfo and allFunctionInfo both to get next info. Or I have to call twice that method If I am not sending them both together. In both cases the operation complexity is same. Iterating over two collection list.
I am curious to know is there any way to collect both child object collections into the BaseInfo collection. something like
Map<String, List<BaseInfo>> allInfo = componentLayer.findById(Id, true);
allInfo = functionLayer.findById(Id);
Basic upper casting I tried but the collection looks like work different way. Is there any way I can type cast a whole child collection to parent collection. It will be great help if one could help.