I have an object graph and one of the accessor methods returns a java Optional and as a result my XPath expression stops from that point onwards.
The xpath is data/someData[1]/optionalObject/field
How can I get JXPath to return the actual object rather than the Optional or does JXPath pre date java Optionals and so it will never work?
If anyone is interested I solved the issue with Optional objects by creating a custom NodePointerFactory instance. I could not find any documentation on doing this, but I hope the below helps anyone who comes across this problem as well.
Steps are as follows.
Register the instance with the call
JXPathContextReferenceImpl.addNodePointerFactory(new OptionalHandlerPointerFactory());The implementation
private static class OptionalHandlerPointerFactory implements NodePointerFactory {
}