的问题: 的
Fasterxml可以在setter中使用抽象时构造一个对象。见下面的代码
Can not construct instance of CarState, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information
的代码: 的
@MappedSuperclass
@Inheritance(strategy= InheritanceType.SINGLE_TABLE)
public interface IState {}
public class BusState implements IState{}
//register subtype in mapper
mapper.registerSubtypes(BusState .class);
public interface Car {
public void setState(IState state);
}
@Entity
public class Bus implements Car {
private BusState state;
public void getState(BusState state) { //Seems fasterxml doesn't use this method, instead it use Car.setState
this.state = state;
}
}
我可以在Bus
课程中创建两种不同的方法:一种用于设置IState
,另一种用于BusState
。但它看起来很难看。
的问题: 的
如何使quickxml正确构造Bus
- 对象?