<div dir="auto"><div>Nice. I presume the definition would look like:<div dir="auto"><br></div><div dir="auto">implements ValueExtractor&lt;@ExtractedValue (type=Integer.class) OptionalInt&gt;</div><div dir="auto"><br></div><div dir="auto">* Should we be really brave and rename or alias that member to value()?</div><div dir="auto">* Should we permit to specify as int.class and force the implementation to wrap? (I haven&#39;t tried it, and also haven&#39;t been awake very long, but I can&#39;t think why it wouldn&#39;t work)</div><div dir="auto"><br></div><div dir="auto">Thanks,</div><div dir="auto">Matt</div><br><div class="gmail_extra"><br><div class="gmail_quote">On May 17, 2017 5:30 AM, &quot;Gunnar Morling&quot; &lt;<a href="mailto:gunnar@hibernate.org">gunnar@hibernate.org</a>&gt; wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Guillaume has looked into adding the type() member to @ExtractedValue<br>
so OptionalInt et al. can be handled via value extractors. All looks<br>
good and the change to the API has already been merged<br>
(<a href="https://github.com/beanvalidation/beanvalidation-api/pull/107" rel="noreferrer" target="_blank">https://github.com/<wbr>beanvalidation/beanvalidation-<wbr>api/pull/107</a>).<br>
<br>
I&#39;ll send a PR with the corresponding spec change in a bit. It should<br>
be part of the update to the Public Review Draft which I&#39;ve planned to<br>
submit to the JCP today. I originally thought I&#39;d have a few more days<br>
time for that, but it turned out that contradictory information was<br>
given on <a href="http://jcp.org" rel="noreferrer" target="_blank">jcp.org</a> (they are going to fix that) and that an update must<br>
not be sent later than 10 days before the PD phase&#39;s end.<br>
<br>
Should any issues come up around this change (or anything else, for<br>
that matter) we can address them as part of the Proposed Final Draft,<br>
which we&#39;ll need to submit in a bit more than one month from now<br>
(around June 20th).<br>
<br>
Cheers,<br>
<br>
--Gunnar<br>
<div class="elided-text"><br>
<br>
<br>
<br>
<br>
2017-05-11 18:42 GMT+02:00 Matt Benson &lt;<a href="mailto:mbenson@apache.org">mbenson@apache.org</a>&gt;:<br>
&gt; On Thu, May 11, 2017 at 2:31 AM, Gunnar Morling &lt;<a href="mailto:gunnar@hibernate.org">gunnar@hibernate.org</a>&gt; wrote:<br>
&gt;&gt; 2017-05-10 20:39 GMT+02:00 Matt Benson &lt;<a href="mailto:mbenson@apache.org">mbenson@apache.org</a>&gt;:<br>
&gt;&gt;&gt; On Wed, May 10, 2017 at 11:34 AM, Gunnar Morling &lt;<a href="mailto:gunnar@hibernate.org">gunnar@hibernate.org</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt; Hi Matt,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Putting the specific spec wording aside for a moment, how would such<br>
&gt;&gt;&gt;&gt; extractor implementation make it possible to tell the wrapped type?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; When validating a constraint on an element of type OptionalInt, the<br>
&gt;&gt;&gt;&gt; validation engine needs to know that this &quot;behaves as an int&quot;, so it<br>
&gt;&gt;&gt;&gt; can determine the applicable constraint validators. For something like<br>
&gt;&gt;&gt;&gt; List&lt;@Email String&gt; we can obtain that information from the type<br>
&gt;&gt;&gt;&gt; argument (so we know we need to look for validators on String), but<br>
&gt;&gt;&gt;&gt; it&#39;s not doable for OptionalInt which doesn&#39;t bear any hint that it is<br>
&gt;&gt;&gt;&gt; about int. Hence the idea of extending the @ExtractedValue annotation<br>
&gt;&gt;&gt;&gt; to convey that information in such case.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; That&#39;s the thing: I can see that perhaps as an implementation detail,<br>
&gt;&gt;&gt; but I can&#39;t actually see how the spec communicates that it&#39;s<br>
&gt;&gt;&gt; absolutely necessary that the implementation know up-front what the<br>
&gt;&gt;&gt; expected type is. A different perspective could come away with the<br>
&gt;&gt;&gt; expectation that the ValueExtractor pass objects to the ValueReceiver<br>
&gt;&gt;&gt; and *then* the implementation inspects the values received to<br>
&gt;&gt;&gt; determine which constraints to apply.<br>
&gt;&gt;<br>
&gt;&gt; It&#39;s the spirit of the spec that the declared type of a constrained<br>
&gt;&gt; element (property, parameter, etc., and now also container elements)<br>
&gt;&gt; is the basis for constraint validator resolution (see 5.7.4).<br>
&gt;<br>
&gt; Fair enough. :)<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; It also mentions the possibility to create an annotation processor for<br>
&gt;&gt; checking that constraints are only put to elements as supported by<br>
&gt;&gt; available constraint validators (&quot;rules can be statically checked&quot;).<br>
&gt;&gt;<br>
&gt;&gt; Basing validator resolution on the received type as you suggest would<br>
&gt;&gt; deviate from this, which is why I think we shouldn&#39;t do it.<br>
&gt;&gt;<br>
&gt;&gt;&gt; The only place where this is<br>
&gt;&gt;&gt; problematic is on the #keyedValue() calls, because you&#39;d have to<br>
&gt;&gt;&gt; inspect the nodeName to know which argument to apply constraints to.<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m not sure I&#39;m following on this one. Can you elaborate?<br>
&gt;<br>
&gt; The spec says that #keyedValue() will be called twice per Map entry:<br>
&gt; once per key and once per value, but the method signature includes<br>
&gt; both the key and value along with the node name, so AFAICT you&#39;d have<br>
&gt; to consider whether the node name  is &quot;&lt;map key&gt;&quot; or &quot;&lt;map value&gt;&quot; to<br>
&gt; know which parameter was referenced. Or is the intent that the call<br>
&gt; for the key repeat the key as both the key and value parameters? That<br>
&gt; could make more sense, but I don&#39;t find the spec to be crystal clear<br>
&gt; on that point if that is indeed the intent.<br>
&gt;<br>
&gt; Matt<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Matt<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; --Gunnar<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; 2017-05-10 17:33 GMT+02:00 Matt Benson &lt;<a href="mailto:mbenson@apache.org">mbenson@apache.org</a>&gt;:<br>
&gt;&gt;&gt;&gt;&gt; On Wed, May 10, 2017 at 9:17 AM, Gunnar Morling &lt;<a href="mailto:gunnar@hibernate.org">gunnar@hibernate.org</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;&gt; 2017-05-10 3:59 GMT+02:00 Matt Benson &lt;<a href="mailto:mbenson@apache.org">mbenson@apache.org</a>&gt;:<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; On Tue, May 9, 2017 at 8:36 AM, Gunnar Morling &lt;<a href="mailto:gunnar@hibernate.org">gunnar@hibernate.org</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Hi,<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; I&#39;m curious about your take on supporting the types in ${subject}<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; (BVAL-579 [1]).<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; They are non-generic wrappers for int, long and double. Should we<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; support them with the numeric constraints such as @Min et al.? The<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; easiest way to do so would be to just mandate support in the JavaDoc<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; of the numeric constraint types.<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; The only thing I can see speaking against this is that we may migrate<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; to an extractor-based approach in a future revision. Currently<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; extractors cannot be used, as those types don&#39;t have any type<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; parameter which could be extracted. But assuming we extend the<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; extractor API in a future revision to deal with non-generic types,<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; too, we could then rather mandate built-in extractors for those types.<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Which will allow to put *any* constraint applying to int also to<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; OptionalInt.<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; Wait... the current draft of the spec still mentions implicit<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; unwrapping of containers. Is that not staying? Why can&#39;t we have e.g.<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; an extractor of OptionalInt to Integer, returning an absent value as<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; null?<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; Implicit unwrapping is staying, but value extraction cannot be used as<br>
&gt;&gt;&gt;&gt;&gt;&gt; is, as we&#39;d lack a way for obtaining the wrapped type from a value<br>
&gt;&gt;&gt;&gt;&gt;&gt; extractor for a non-generic type:<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;     OptionalIntExtractor implements ValueExtractor&lt;@ExtractedValue<br>
&gt;&gt;&gt;&gt;&gt;&gt; OptionalInt&gt; {<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;     }<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; There is no type parameter/argument from which the wrapped type (int)<br>
&gt;&gt;&gt;&gt;&gt;&gt; could be obtained (which is needed for finding the right constraint<br>
&gt;&gt;&gt;&gt;&gt;&gt; validator). We could add an attribute to @ExtractedValue for such<br>
&gt;&gt;&gt;&gt;&gt;&gt; cases: @ExtractedValue(wrappedType=<wbr>int.class).<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; We could do this in a future revision or if we are confident about it<br>
&gt;&gt;&gt;&gt;&gt;&gt; in the Proposed Final draft. We are going to explore it in the RI (by<br>
&gt;&gt;&gt;&gt;&gt;&gt; using a separate annotation next to @ExtractedValue for the time<br>
&gt;&gt;&gt;&gt;&gt;&gt; being).<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Okay, I hadn&#39;t investigated the JavaFX APIs and hadn&#39;t realized that<br>
&gt;&gt;&gt;&gt;&gt; e.g. StringProperty and IntegerProperty did have a generic type<br>
&gt;&gt;&gt;&gt;&gt; parameter up their hierarchy. I still don&#39;t know that I believe the<br>
&gt;&gt;&gt;&gt;&gt; specification is fully consistent in this regard then, because section<br>
&gt;&gt;&gt;&gt;&gt; 5.5.1 refers to these as &quot;non-generic property types.&quot; I see that the<br>
&gt;&gt;&gt;&gt;&gt; unwrapping for these types is intended to be fulfilled by<br>
&gt;&gt;&gt;&gt;&gt; ValueExtractor&lt;<wbr>ObservableValue&lt;@<wbr>ExtractedValue T&gt;&gt;, but the<br>
&gt;&gt;&gt;&gt;&gt; &quot;non-generic property types&quot; wording, to me, is suggestive of, and I<br>
&gt;&gt;&gt;&gt;&gt; think this has been discussed, something like a ValueExtractor that:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; * does *not* bear an @ExtractedValue annotation, and<br>
&gt;&gt;&gt;&gt;&gt; * *must* be marked as @UnwrapByDefault<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Then it seems an implementation would provide something like:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; @UnwrapByDefault<br>
&gt;&gt;&gt;&gt;&gt; public class OptionalIntExtractor implements ValueExtractor&lt;OptionalInt&gt; {<br>
&gt;&gt;&gt;&gt;&gt;   void extractValues(OptionalInt originalValue, ValueReceiver receiver) {<br>
&gt;&gt;&gt;&gt;&gt;     if (originalValue.isPresent()) {<br>
&gt;&gt;&gt;&gt;&gt;       receiver.value(null, originalValue.getAsInt());<br>
&gt;&gt;&gt;&gt;&gt;     }<br>
&gt;&gt;&gt;&gt;&gt;   }<br>
&gt;&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; This seems so simple that perhaps I am missing something; what is it? :)<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Matt<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; Matt<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Should we do such change in a future revision, I don&#39;t think anything<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; would change for users. Only providers would have to implement support<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; for these types via extractors instead of dedicated constraint<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; validators. I think such change is acceptable.<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; What do others think?<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Thanks,<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; --Gunnar<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; [1] <a href="https://hibernate.atlassian.net/browse/BVAL-579" rel="noreferrer" target="_blank">https://hibernate.atlassian.<wbr>net/browse/BVAL-579</a><br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; beanvalidation-dev mailing list<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; <a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.<wbr>jboss.org</a><br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/<wbr>beanvalidation-dev</a><br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; beanvalidation-dev mailing list<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; <a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.<wbr>jboss.org</a><br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/<wbr>beanvalidation-dev</a><br>
&gt;&gt;&gt;&gt;&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt;&gt;&gt;&gt;&gt; beanvalidation-dev mailing list<br>
&gt;&gt;&gt;&gt;&gt;&gt; <a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.<wbr>jboss.org</a><br>
&gt;&gt;&gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/<wbr>beanvalidation-dev</a><br>
&gt;&gt;&gt;&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt;&gt;&gt;&gt; beanvalidation-dev mailing list<br>
&gt;&gt;&gt;&gt;&gt; <a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.<wbr>jboss.org</a><br>
&gt;&gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/<wbr>beanvalidation-dev</a><br>
&gt;&gt;&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt;&gt;&gt; beanvalidation-dev mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.<wbr>jboss.org</a><br>
&gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/<wbr>beanvalidation-dev</a><br>
&gt;&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt;&gt; beanvalidation-dev mailing list<br>
&gt;&gt;&gt; <a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.<wbr>jboss.org</a><br>
&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/<wbr>beanvalidation-dev</a><br>
&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt; beanvalidation-dev mailing list<br>
&gt;&gt; <a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.<wbr>jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/<wbr>beanvalidation-dev</a><br>
&gt; ______________________________<wbr>_________________<br>
&gt; beanvalidation-dev mailing list<br>
&gt; <a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.<wbr>jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/<wbr>beanvalidation-dev</a><br>
______________________________<wbr>_________________<br>
beanvalidation-dev mailing list<br>
<a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.<wbr>jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/<wbr>beanvalidation-dev</a><br>
</div></blockquote></div><br></div></div></div>