I have multiple root elements and thus, I need to write
JAXBElement<BookType> jaxbBookType = objectFactory.createBookType (bookType);
JAXBElement<OrderType> jaxbOrderType = objectFactory.createOrderType (orderType);
and so on. I don't want to write this piece of code again and again. I am trying to write a method which will return me JAXBElement based on its input.
What i am trying to write is
public <T> JAXBElement<T> getJaxbElement (Object obj){
if (obj instanceof OrderType){
return objectFactory.createOrderType((OrderType)obj);
}
}
But obviously, I am doing it wrong. Since i don't know much about Generics and after reading it for a while, I am still confuse. Can someone help me little bit here.