Using generics when inheriting a given class