我有以下代码:
public interface CreatorFactory<E extends Vehicle> {
public VehicleType<E> getVehicle();
public boolean supports(String game);
}
public abstract AbstractVehicleFactory<E extends Vehicle> implements CreatorFactory {
public VehicleType<E> getVehicle() {
// do some generic init
getVehicle();
}
public abstract getVehicle();
public abstract boolean supports(String game);
}
我有多家工厂,用于汽车、卡车等。
@Component
public CarFactory extends AbstractVehicleFactory<Car> {
/// implemented methods
}
@Component
public TruckFactory extends AbstractVehicleFactory<Truck> {
/// implemented methods
}
我想做的是将实现的工厂作为一个列表拉到一个单独的类中,但我不确定泛型在这种情况下是如何工作的......我知道在春天你可以获得特定类型的所有bean......这会不会还上班吗?...
通过擦除,我猜泛型类型将被删除.. ??