There is a collection class with the
get method, which, depending on the parameters passed, can return an instance of one of the three classes. The only thing in common between classes is that they can all be in this collection.
How from the point of view of architecture it is better to solve this problem?
- Inherit all three classes from the same abstract, so that the user himself checks the type and castile.
- To do as in
StreamTokenizer: get an
Enumwith three values, and a
getType()function that returns this
Enum. The user calls
getTypeand, depending on the result, gets the value using one of the three
- Own option.