<div dir="ltr">Gunnar,<div><br></div><div>Maybe I&#39;m missing the point here, but as far as I understand, names added to the paths will be significant - for instance, it will influence how messages will end up being formatted, because keys will now depend on this additional information, right? If this is wrong, then disregard what I wrote below because it&#39;s based on that assumption.</div><div><br></div><div>When you rename a property or a class name, client code will very likely fail to compile. You&#39;re releasing an incompatible change - you probably need to bump your major version in some cases and write thorough release notes in order to do that. Now, we&#39;re saying that to BeanValidation - and so far, in JCP standards, the only one AFAIK -, type parameter *names* are relevant. If you rename one, your code will compile but you might end up having a runtime exception or a poorly formatted error message because of that, unless you explicitly test them for type parameter name change - the only change that will not break other parts of your code. Whereas if you really on order, a change either breaks compilation or completely changes the semantics of existing code and has to follow the incompatible change process.</div><div><br></div><div>But, as I said, what I said above is only valid if the names are significant, i.e., used somewhere else in a meaningful way.</div><div><br></div><div>Regards,</div><div>Michael</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 22, 2017 at 2:13 PM, Gunnar Morling <span dir="ltr">&lt;<a href="mailto:gunnar@hibernate.org" target="_blank">gunnar@hibernate.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">&gt; Looks bad, type parameter names in Java are considered documentation and not<br>
&gt; something you cannot change during class evolution. For Map, it won&#39;t ever<br>
&gt; change, but for other domain classes, it can change.<br>
<br>
</span>Property paths reflect on a model in a given state. If your model<br>
evolves, e.g. because you rename a bean property, paths obtained<br>
previously may not match any element in the model&#39;s current state<br>
anymore.<br>
<br>
I.e. I&#39;m failing to see the how the situation is fundamentally<br>
different for type parameters?<br>
<div><div class="h5"><br>
2017-02-22 17:46 GMT+01:00 Michael Nascimento &lt;<a href="mailto:misterm@gmail.com">misterm@gmail.com</a>&gt;:<br>
&gt; On Wed, Feb 22, 2017 at 1:10 PM, Guillaume Smet &lt;<a href="mailto:guillaume.smet@gmail.com">guillaume.smet@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; = 1. Type parameter information<br>
&gt;&gt;<br>
&gt;&gt; == 1.1 Should we add the type parameter to the node?<br>
&gt;&gt;<br>
&gt;&gt; Assume the example of a map:<br>
&gt;&gt; private Map&lt;@Valid City (1), @Valid Statistics (2)&gt; map;<br>
&gt;&gt;<br>
&gt;&gt; With the current way of doing things, you end up with the following paths:<br>
&gt;&gt; (1) (name = map, type = PROPERTY) -&gt; (name = name, type = PROPERTY,<br>
&gt;&gt; isInIterable = true, key = city)<br>
&gt;&gt; (2) (name = map, type = PROPERTY) -&gt; (name = count, type = PROPERTY,<br>
&gt;&gt; isInIterable = true, key = city)<br>
&gt;&gt;<br>
&gt;&gt; So you wouldn&#39;t be able to differentiate if the violations is coming from<br>
&gt;&gt; City or Statistics.<br>
&gt;&gt;<br>
&gt;&gt; One of the ideas we had is to integrate the TypeVariable&lt;?&gt; type parameter<br>
&gt;&gt; info into the last node. In the case of (1), you would have 2 nodes:<br>
&gt;&gt; (1) (name = map, type = PROPERTY) -&gt; (name = name, type = PROPERTY,<br>
&gt;&gt; isInIterable = true, key = city, typeParameter = K)<br>
&gt;&gt; (2) (name = map, type = PROPERTY) -&gt; (name = count, type = PROPERTY,<br>
&gt;&gt; isInIterable = true, key = city, typeParameter = V)<br>
&gt;&gt;<br>
&gt;&gt; WDYT?<br>
&gt;<br>
&gt;<br>
&gt; Looks bad, type parameter names in Java are considered documentation and not<br>
&gt; something you cannot change during class evolution. For Map, it won&#39;t ever<br>
&gt; change, but for other domain classes, it can change.<br>
&gt;<br>
&gt; Type parameter *order*, though, cannot change without change meaning, so<br>
&gt; that&#39;s the best option we have left :-(<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; == 1.2 If we add this information, what should it be?<br>
&gt;&gt;<br>
&gt;&gt; At first, Gunnar thought about using java.lang.reflect.TypeVariable for<br>
&gt;&gt; this type parameter information but we have an issue with it: it is not<br>
&gt;&gt; serializable and the path is supposed to be.<br>
&gt;&gt;<br>
&gt;&gt; Thus we need to either use a String with the name of the type parameter or<br>
&gt;&gt; introduce our own serializable structure.<br>
&gt;<br>
&gt;<br>
&gt; Introduce a serializable structure. :-(<br>
&gt;<br>
&gt;&gt; What&#39;s your take on this? If we go the structure route, which information<br>
&gt;&gt; should this structure contain apart from the name?<br>
&gt;&gt; java.lang.reflect.TypeVariable also has the generic declaration information.<br>
&gt;&gt;<br>
&gt;&gt; Do you foresee issues if we are not using java.lang.reflect.<wbr>TypeVariable?<br>
&gt;&gt; Typically it would be harder to do additional reflection things.<br>
&gt;<br>
&gt;<br>
&gt; Yeah, as the generics model evolve, we might paint ourselves in the corner.<br>
&gt;<br>
&gt;&gt; = 2. Type argument constraints<br>
&gt;&gt;<br>
&gt;&gt; So, the discussion above also applies to type argument constraints but<br>
&gt;&gt; there are some specific questions for them.<br>
&gt;&gt;<br>
&gt;&gt; == 2.1 New node type<br>
&gt;&gt;<br>
&gt;&gt; Type argument constraints cover the following case, ZipCode being a<br>
&gt;&gt; constraint:<br>
&gt;&gt; Map&lt;@ZipCode String, String&gt; map;<br>
&gt;&gt;<br>
&gt;&gt; In this case, we envision the following node structure (assuming we would<br>
&gt;&gt; add the typeParameter discussed in 1.1):<br>
&gt;&gt; (name = map, type = property) -&gt; (name = &#39;&lt;map key&gt;&#39;, type =<br>
&gt;&gt; TYPE_ARGUMENT, isInIterable = true, key = myKey, typeParameter = K)<br>
&gt;&gt;<br>
&gt;&gt; TYPE_ARGUMENT is a new type introduced in javax.validation.ElementKind.<br>
&gt;&gt;<br>
&gt;&gt; Does it make sense?<br>
&gt;<br>
&gt;<br>
&gt; My answer from above applies here as well.<br>
&gt;<br>
&gt;&gt; == 2.2 Default node names<br>
&gt;&gt;<br>
&gt;&gt; The default extractors define the following node names for the added<br>
&gt;&gt; TYPE_ARGUMENT node:<br>
&gt;&gt; - arrays and Iterables (List included): &lt;iterable element&gt;<br>
&gt;&gt; - Map key: &lt;map key&gt;<br>
&gt;&gt; - Map value: &lt;map value&gt;<br>
&gt;&gt;<br>
&gt;&gt; This is similar to the nodes we created for &quot;&lt;return value&gt;&quot; or<br>
&gt;&gt; &quot;&lt;cross-parameter&gt;&quot; constraints.<br>
&gt;&gt;<br>
&gt;&gt; Question: should they have a node name? should it be the type parameter<br>
&gt;&gt; name instead (so E or K or V for instance)?<br>
&gt;&gt;<br>
&gt;&gt; Note that this might have consequences in the string representation we<br>
&gt;&gt; will discuss later.<br>
&gt;<br>
&gt;<br>
&gt; If they must have a name, it will probably have to be named after the types<br>
&gt; they apply to and type parameter order :-(<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; == 2.3 Optional and ObservableValue<br>
&gt;&gt;<br>
&gt;&gt; In these 2 cases, we won&#39;t append a node.<br>
&gt;&gt;<br>
&gt;&gt; Note that while in the ObservableValue case, it might feel more natural as<br>
&gt;&gt; the constraint will probably be used like:<br>
&gt;&gt; @NotBlank StringProperty property;<br>
&gt;&gt; to apply a NotBlank constraint on the wrapped value so it&#39;s rather logical<br>
&gt;&gt; to not have a node.<br>
&gt;&gt;<br>
&gt;&gt; Just to be clear, for Optional, on the other hand, with our proposal, we<br>
&gt;&gt; won&#39;t have a node whereas the code looks like:<br>
&gt;&gt; Optional&lt;@NotBlank String&gt; optional;<br>
&gt;<br>
&gt;<br>
&gt; Couldn&#39;t quite understand what comments I could make about it, so ok :-)<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; = 3 String representation<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Note: this is implementation specific but we thought it might be<br>
&gt;&gt; interesting to discuss it here anyway.<br>
&gt;<br>
&gt;<br>
&gt; Sorry, too many nuances and I don&#39;t have a strong opinion here.<br>
&gt;<br>
&gt; Regards,<br>
&gt; Michael<br>
&gt;<br>
</div></div>&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>
</blockquote></div><br></div>