java XmlAdapter, is it possible to find out which

2019-08-05 08:35发布

I've few of Java Enums which needs to mapped. I implement a XmlAdapter for marshalling and unmarshalling purpose.

I would like to make the enums generic that I can call similar method of the enums from XmlAdapter. I also introduced an interface where all the enums implementing them.

@XmlJavaAdapter(MyAdapter.class)
public enum A implements Hello {
doSomething1();
doSomething2();
}

@XmlJavaAdapter(MyAdapter.class)
public enum B implements Hello {
doSomething1();
doSomething2();
}

MyAdapter extends XmlAdapter<String, Enum> {
 Enum unmarshal(String s){
     // I would like to return the correct enum from the Enums those who sharing this adapter
  }
}

Any idea? Thanks

0条回答
登录 后发表回答