I have a fairly complex XML schema and I use hyperjaxb3 to generate pojo's with annotations for. There are times when I have the parent object and would like to check the value of a child object that may be 8 or 9 children deep. Is there anyway to use jaxb, or another tool, to get a list of child objects of a specific class based on jaxb annotations?
I could write a recursive function to search all children for an instance of a class but that would be less than ideal. Any advise would be appreciated, thanks.
You don't have to write the code to walk the object tree yourself — there are a few out there already (jdereg's java-util for example), and the
JAXBIntrospectorwill find objects annotated withXmlRootElementfor you. There would be a little more work required if you're looking for other annotations, but not much.For example: