我有:
public abstract class HistorizableStatusEntity<S extends Status,
O extends IdentifiedEntity> extends IdentifiedEntity
具体实施:
public class OrderStatusHistory extends HistorizableStatusEntity<OrderStatus, Order>
现在有:
public abstract class StatusableEntity<H extends HistorizableStatusEntity<S, IdentifiedEntity>,
S extends Status> extends IdentifiedEntity
具体实施:
public class Order extends StatusableEntity<OrderStatusHistory, OrderStatus>
java编译器说Order
:
Bound mismatch: The type OrderStatusHistory is not a valid substitute for the bounded parameter <H extends HistorizableStatusEntity<S,IdentifiedEntity>> of the type StatusableEntity<H,S>
我不明白这一点,因为 OrderStatusHistory 扩展了HistorizableStatusEntity<S,IdentifiedEntity>>
。
有什么想法吗? TIA!
答案 0 :(得分:2)
StatusableEntity
期望类型为H extends HistorizableStatusEntity<S, IdentifiedEntity>
,而您提供的OrderStatusHistory
会扩展为HistorizableStatusEntity<OrderStatus, Order>
。如您所见,正确的类型与StatusableEntity
期望的内容不匹配(Order
与IdentifiedIdentity
不匹配)。