我有一些看起来像这样的类:
模型
public abstract class BaseEntity<O extends Object> { ... } public class Person extends BaseEntity<Person> { ... }
命令
public abstract class BaseCommand<BE extends BaseEntity<BE>> { ... } public class PersonCommand extends BaseCommand<Person> { ... }
服务
public interface BaseService<BE extends BaseEntity<BE>> { public BE create(BaseCommand<BE> command); } public interface PersonService extends BaseService<Person> { ... }
服务进展
public abstract class BaseServiceImpl<BE extends BaseEntity<BE>> implements BaseService<BE> { } public class PersonServiceImpl extends BaseServiceImpl<Person> implements PersonService { public Person create(PersonCommand personCommand) { ... } }
PersonServiceImpl类不会编译.它没有意识到create()方法正在从BaseService接口实现create()方法.任何人都可以告诉为什么PersonCommand没有被识别为BaseCommand< BE> (在参数列表中)?