I have a list of entities. Each entity inherits some base class. In the controller I should determine a corresponding view for each entity object. How should I do that?
class BaseEntity {}
class FooEntity extends BaseEntity {}
class BarEntity extends BaseEntity {}
class View {}
class FooView extends View {}
class BarView extends View {}
Controller code:
BaseEntitty entities = repository.getSomeEntities();
List<View> views = new ArrayList();
for(BaseEntity in entities) {
View view; //How can I determine the concrete view class?
views.add(view);
}
P.S. A proper OOP solution is preferable.
Aucun commentaire:
Enregistrer un commentaire