Consider that object wrapped in DataContainer will be handed out to client
// Will be handed out
public interface DataContainer
In order to use it, client currently needs to know to cast the object to:
public interface ConcreteObject_1_Container extends DataContainer
public interface ConcreteObject_2_Container extends DataContainer
Is it possible to offer both ConcreteObject1Container and ConcreteObject2Container as options to be chosen from, similar to how Enum options can be picked?
Instead of user magically knowing to use FileContainer
// user knows
FileContainer fileContainer = (FileContainer)
ContainerFactory.getContainerFor(DataSource.FILE,
TREAT_AS_SOURCE);
I'd like to
// user selects
FileContainer fileContainer = (GenericContainer.FileContainer)
ContainerFactory.getContainerFor(DataSource.FILE,
TREAT_AS_SOURCE);
You should probably change your design. Either:
DataContainer, without caring what implementation it is, in which case the cast can be avoided, orIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With