java XmlAdapter, is it possible to find out which enums are using that adapter?

浪子不回头ぞ 提交于 2019-12-24 16:18:25

问题


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

来源:https://stackoverflow.com/questions/31006981/java-xmladapter-is-it-possible-to-find-out-which-enums-are-using-that-adapter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!