<div dir="ltr">







<p class="">Thought.</p><p class="">It seems very easy to do things with the fluent builder API that either have no effect or have little effect - such as:</p><p class="">new ConfigurationBuilder().clustered().clustered().clustered()</p>
<p class="">While this is probably not a problem. The call to `.clustered()` could return a sub-configuration interface that would ultimately return an intermediate interface, only declaring methods that may be used to configure a cluster - thus making such a declaration syntactically illegal. Once a valid configuration state on this object (and its sub-objects) is reached, the returned interface type would present the user with a `ClusteredConfigurationBuilder`, e.g. a ConfigurationBuilder that is already clustered, and cannot be used to configure a cluster.</p>
<p class="">I&#39;m fully aware of how many interfaces this would require, but I also have a proof of concept that has shown to be very practically successful in eliminating user error for complex configurations, and has been well worth the effort:</p>
<p class=""><a href="https://github.com/ocpsoft/rewrite/blob/master/api-tests/src/test/java/org/ocpsoft/rewrite/config/ConfigurationBuilderTest.java#L247">https://github.com/ocpsoft/rewrite/blob/master/api-tests/src/test/java/org/ocpsoft/rewrite/config/ConfigurationBuilderTest.java#L247</a><br>
</p><p class="">The above test does not verify invalid configuration ordering because it is actually a compilation error and cannot be tested with JUnit! But hopefully you get the idea.</p><p class="">You can see the hierarchy of this (probably simpler than infinispan) configuration builder API here:</p>
<p class=""><a href="https://github.com/ocpsoft/rewrite/tree/master/api/src/main/java/org/ocpsoft/rewrite/config">https://github.com/ocpsoft/rewrite/tree/master/api/src/main/java/org/ocpsoft/rewrite/config</a><br></p><p class="">
Any class that starts with &quot;Configuration...&quot; is part of the relevant API.</p><p class="">Also, you could avoid an API-breaking change if provided a TypesafeConfigurationBuilder that simply delegates to the current ConfigurationBuilder API.</p>
<p class=""><br></p><p class="">Thoughts?</p>-- <br>Lincoln Baxter, III<br><a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a><br>&quot;Simpler is better.&quot;
</div>