I use JAXB to generate POJOs from a WADL xsd. I downloaded the xsd directly from W3C. However, I'd like one of my POJOs to have a helper method that allows me to recurse through it, like so:
public Stream<WadlResource> flattenPath() {
return Stream.concat(
Stream.of(this),
this.methodOrResource.stream()
.filter(WadlResource.class::isInstance)
.map(WadlResource.class::cast)
.flatMap(WadlResource::flattenPath) // recursion here
);
}
Notice the use of this
. This method is the only way I've seen of recursing with a stream.
So my question is: How do I add this method so that it is generated along with the xsd? Is that good practice? Or should I just generate the code once, add the method, and check it into my repo (which DOESN'T seem like good practice). TIA!