首先对我糟糕的英语感到抱歉。我想解组而不是编组以下类。
@XmlSeeAlso({B1.class, C1.class})
public abstract class A1 implements Serializable {
private String parameterName;
public A1 () {
}
public A1 (String parameterName) {
this.parameterName = parameterName;
}
public String getParameterName() {
return parameterName;
}
}
子类
public class B1 extends A1{
@SuppressWarnings("rawtypes")
private Collection dataSource = new ArrayList();
public B1 () {
}
@SuppressWarnings("rawtypes")
public B1 (String parameterName, Collection dataSource) {
super(parameterName);
this.dataSource = dataSource;
}
@SuppressWarnings("rawtypes")
public B1 (Collection dataSource) {
super("B");
this.dataSource = dataSource;
}
@SuppressWarnings("rawtypes")
public Collection getDataSource() {
return dataSource;
}
和
public class C1 extends A1 {
private String imagePath;
public C1() {
}
protected C1(String parameterName) {
super(parameterName);
}
public C1 (String parameterName, String imagePath) {
super(parameterName);
this.imagePath = imagePath;
}
public String getImagePath() {
return imagePath;
}
子类在一个集合中
List<? extends A1>
解组和编组后的字段将为空(例如:parameterName)。该应用程序不会引发任何异常。