WebDAV uses rather complex XML for its entities, and currently one must
write a lot of nested constructors to create valid bodies:
return new MultiStatus(new Result(x), new Result(y);
As fluent APIs are trendy due to its much improved readbility, and since
JAX-RS itself comes with ResponseBuilders having fluent APIs, I want to add
something like a fluent "WebDavBuilder" which makes creation of responses
easier.
Unfortunately I am not much used to fluent APIs and recognized that
designing a *good* fluent API is not so easy.
For example, how to add multiple instances of the same class to a root
element?
return WebDavBuilder.multiStatus().result(x).result(y); ?
return WebDavBuilder.multiStatus(new Result(x), new Result(y)); ?
...?
Since a lot of people are participating to this forum having much more
experience with fluent APIs than I have, I want to ask all of those gurus:
What is the best way to design that? Currently both of my ideas seem to be
not any better that the original nested-constructors-approach... :-(
Thanks!
Markus