How do I marshal a list of JAXB annotated objects without creating another class whose sole purpose is to be a container for the annotated objects?
Say I have this list:
List<MyObj> myList = new ArrayList<>();
List
is a great container for objects, how can I marshal myList
? I'm looking for an example that takes about 4 lines of code (about how much it takes to marshal a single MyObj
instance) without creating any special helper classes.
I would accept an answer that had a generic helper class that could hold an arbitrary object type, like the List
interface or the ArrayList
class. That way I could reuse the helper class for all my applications.