[I realize this is better done with protocols; but I'm exploring a class-only approach with this question!] Assume I have the following generic type defined:
class Entity<Identifier:Equatable> {
var identifier : Identifier
// init, etc
}
Now, following a DAO-ish pattern, I would like to define:
class EntityDAO<Entity:Entity> {
var entities : [Entity]
// ...
}
Of course, the above won't compile because the 'Identifier' for 'Entity' is not mentioned. Is there a way to define EntityDAO with a single generic type for Entity?
The other option is, with two generic types:
class EntityDAOToo<I:Equatable, E:Entity<I>> { ... }
But I prefer not to specify 'I'. The use would be
class Person : Entity<String> { ... }
class PersonDao : EntityDao<Person> { ... }