<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">The naming in the bootstrap API was lacking some consistency and was a bit obscure at time<div><br></div><div>I went back tot he drawing board and came with something that is I think more natural and thus easier to use:</div><div>&nbsp;- to build&nbsp;<font class="Apple-style-span" face="'Courier New'">ValidatorFactory</font></div><div>&nbsp;- to build<font class="Apple-style-span" face="'Courier New'"> Validator</font></div><div><br></div><div>Each set of proposal change is followed by the old and new syntax. Feedback welcome.</div><div><br></div><div><b>To Build a ValidatorFactory</b></div><div><br></div><div>Here are the proposed changes</div><div><font class="Apple-style-span" face="'Courier New'">ValidatorFactoryBuilder</font>&nbsp;=>&nbsp;<font class="Apple-style-span" face="'Courier New'">Configuration</font>&nbsp;(should it be&nbsp;<font class="Apple-style-span" face="'Courier New'">ValidatorFactoryConfiguration</font>)</div><div><font class="Apple-style-span" face="'Courier New'">Validation.builderType(Class&lt;T>)</font>&nbsp;to&nbsp;<font class="Apple-style-span" face="'Courier New'">Validation.byProvider(Class&lt;T>)</font></div><div><font class="Apple-style-span" face="'Courier New'">Validation.defineBootstrapState()<span class="Apple-style-span" style="font-family: Helvetica; ">&nbsp;to</span>&nbsp;Validation.byDefaultProvider()</font></div><div><font class="Apple-style-span" face="'Courier New'">GenericBuilderFactory.getBuilder()<span class="Apple-style-span" style="font-family: Helvetica; ">&nbsp;to</span>&nbsp;GenericConfigurationFactory.configure()</font></div><div><div><font class="Apple-style-span" face="'Courier New'">SpecializedBuilderFactory.getBuilder()<span class="Apple-style-span" style="font-family: Helvetica; ">&nbsp;to</span>&nbsp;SpecializedConfigurationFactory.configure()</font></div></div><div><font class="Apple-style-span" face="'Courier New'">ValidatorFactoryBuilder.build()&nbsp;<span class="Apple-style-span" style="font-family: Helvetica; ">to</span>&nbsp;Configuration.getValidatorFactory()&nbsp;<span class="Apple-style-span" style="font-family: Helvetica; ">&nbsp;(should it be<span class="Apple-style-span" style="font-family: 'Courier New'; ">&nbsp;buildValidatorFactory()<span class="Apple-style-span" style="font-family: Helvetica; ">?)</span></span></span></font></div><div><font class="Apple-style-span" face="'Courier New'">ValidatorFactoryBuilder.configure()&nbsp;<span class="Apple-style-span" style="font-family: Helvetica; ">to</span>&nbsp;Configuration.customConfiguration()</font></div><div><br></div><div><br></div><div>Also I am considering:</div><div>&nbsp;- removing&nbsp;<font class="Apple-style-span" face="'Courier New'">Validation.getBuilder()</font>&nbsp;(which would have been Validation.configure() )</div><div>&nbsp;- adding&nbsp;<font class="Apple-style-span" face="'Courier New'">Validation.getDefaultValidatorFactory()</font>&nbsp;(which correspond to the default bootstrap strategy used by JPA and JSF unless overridden)</div><div><br></div><div>Here are various bootstraps with the old naming followed by the new naming. You will see that we gain in consistency and expressivity:</div><div>&nbsp;- byProvider(Class&lt;?>) vs byDefaultProvider()</div><div>&nbsp;- the object type retrieved and its purpose is more obvious (configure(), getValidatorFactory())</div><div>&nbsp;- the builder is a configuration object retrieving state to build ValidatorFactory</div><div><br></div><div>//simple bootstrap</div><div><font class="Apple-style-span" face="'Courier New'">ValidatorFactoryBuilder&lt;?> builder = Validation.getBuilder();</font></div><div>=> no equivalent but replaced by</div><div><font class="Apple-style-span" face="'Courier New'">Configuration&lt;?> configuration = Validation.byDefaultProvider().configure();</font></div><div><br></div><div><font class="Apple-style-span" face="'Courier New'">Validation.getBuilder().build();</font></div><div>=></div><div><font class="Apple-style-span" face="'Courier New'">ValidatorFactory factory = Validation.getDefaultValidatorFactory();</font></div><div><br></div><div>//use generic provider with specific resolver strategy</div><div><font class="Apple-style-span" face="'Courier New'">ValidatorFactoryBuilder&lt;?> factoryBuilder =&nbsp;</font></div><div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp;Validation.defineBootstrapState()</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;.providerResolver(...)&nbsp;&nbsp;&nbsp;//optional step</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;.getBuilder();</font></div><div>=></div><div><font class="Apple-style-span" face="'Courier New'">Configuration&lt;?> configuration =&nbsp;</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp;Validation.byDefaultProvider()</font></div><div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;.providerResolver(...) &nbsp; //optional step</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;.configure();</font></div><div><br></div><div>//use a specific provider&nbsp;with specific resolver strategy</div><div><div><font class="Apple-style-span" face="'Courier New'">ValidatorFactoryBuilder&lt;?> factoryBuilder =&nbsp;</font></div><div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp;Validation.builderType(ACMEValidatorFactoryBuilder.class)</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;.providerResolver(...) &nbsp;&nbsp;//optional step</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;.getBuilder();</font></div><div>=></div><div><font class="Apple-style-span" face="'Courier New'">Configuration&lt;?> configuration =&nbsp;</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp;Validation.byProvider(ACMEValidatorConfiguration.class)</font></div><div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;.providerResolver(...) &nbsp;&nbsp;&nbsp;//optional step</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;.configure();</font></div><div><br></div><div>I am also wondering if we should rename the methods on the&nbsp;<font class="Apple-style-span" face="'Courier New'">Configuration</font>&nbsp;object (former&nbsp;<font class="Apple-style-span" face="'Courier New'">ValidatorFactoryBuilder</font>):</div><div><div>&nbsp;-&nbsp;<font class="Apple-style-span" face="'Courier New'">messageResolver</font>&nbsp;=>&nbsp;<font class="Apple-style-span" face="'Courier New'">useMessageResolver</font></div><div>&nbsp;-&nbsp;<font class="Apple-style-span" face="'Courier New'">providerResolver</font>&nbsp;=>&nbsp;<font class="Apple-style-span" face="'Courier New'">useProviderResolver</font></div><div>&nbsp;-&nbsp;<font class="Apple-style-span" face="'Courier New'">traversableResolver</font>&nbsp;=>&nbsp;<font class="Apple-style-span" face="'Courier New'">useTraversableResolver</font></div><div>&nbsp;-&nbsp;<font class="Apple-style-span" face="'Courier New'">customConfiguration</font>&nbsp;=>&nbsp;<font class="Apple-style-span" face="'Courier New'">useCustomConfiguration</font></div><div>&nbsp;-&nbsp;<font class="Apple-style-span" face="'Courier New'">constraintFactory</font>&nbsp;=>&nbsp;<font class="Apple-style-span" face="'Courier New'">useConstraintFactory</font></div></div><div><br></div><div>This makes them a bit more "fluent" but also more verbose.</div><div><br></div><div><span class="Apple-style-span" style="font-weight: bold; ">To Build a Validator</span></div><div><b><br></b></div><div><div>rename&nbsp;<font class="Apple-style-span" face="'Courier New'">ValidatorFactory.defineValidatorState()</font>&nbsp;to&nbsp;<font class="Apple-style-span" face="'Courier New'">ValidatorFactory.usingContext()</font></div><div>rename&nbsp;<font class="Apple-style-span" face="'Courier New'">ValidatorBuilder</font>&nbsp;to&nbsp;<font class="Apple-style-span" face="'Courier New'">ValidatorContext</font></div><div><br></div><div>Here are various bootstraps with the old naming followed by the new naming. We gain consistency with the VF creation as well</div><div><br></div><div><div>//simple validator creation</div><div><font class="Apple-style-span" face="'Courier New'">Validator validator = validatorFactory.getValidator();</font></div><div>=></div><div><font class="Apple-style-span" face="'Courier New'">Validator validator =&nbsp;validatorFactory.getValidator();&nbsp;</font>&nbsp; //unchanged</div><div><br></div><div>//with overriding context</div><div><font class="Apple-style-span" face="'Courier New'">Validator validator =&nbsp;</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp;validatorFactory.defineValidatorState()</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;.traversableResolver(...)</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;.messageResolver(...)</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;.getValidator();</font></div><div>=></div><div><div><font class="Apple-style-span" face="'Courier New'">Validator validator =&nbsp;</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp;validatorFactory.usingContext()</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;.traversableResolver(...)</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;.messageResolver(...)</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;.getValidator();</font></div><div><br></div><div>What do you think?</div><div><br></div><div>There are three layers of changes:</div><div>&nbsp;&nbsp;- having a consistent naming between VF and V creations and using more meaningful name for the build method (ie getValidator / getValidatorFactory</div><div>&nbsp;- having a consistent path and naming wether you use the default provider or a specific one</div><div>&nbsp;- rename the builder classes with meaningful definitions</div></div></div></div></div></div></div></div></div><br><div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><br></div></div></div></div></div></body></html>