<div dir="ltr">Just replying to this one:<div><br></div><div>&gt; <span style="font-size:12.8px">== Constraint on non parameterized containers</span></div><div><span style="font-size:12.8px">&gt; </span><span style="font-size:12.8px">I am liking option 3 less and less and as far as I can remember, it does not rely on an explicitly</span></div><div><span style="font-size:12.8px">&gt; identified use case. Who is wanting to support that usage, vs restrict the container feature to </span></div><div><span style="font-size:12.8px">&gt; parameterized containers?</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I&#39;m not sure where this requirement is coming from. Wouldn&#39;t it simply be addressed by providing a validator for @Min + IntegerContainer? I.e. do we need any explicit support for this at all compared to what&#39;s possible today?</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Also the JavaFX case (your 2nd example around StringProperty) could be satisfied by just adding explicit validators for StringProperty, IntegerProperty etc. Agreed it&#39;s not as elegant/generic and wouldn&#39;t work for custom types. May still be a way forward, though.</span></div><div><div class="gmail_extra"><br><div class="gmail_quote">2016-11-21 14:28 GMT+01:00 Emmanuel Bernard <span dir="ltr">&lt;<a href="mailto:emmanuel@hibernate.org" target="_blank">emmanuel@hibernate.org</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On 7 Nov 2016, at 23:42, Hendrik Ebbers &lt;<a href="mailto:hendrik.ebbers@me.com" target="_blank">hendrik.ebbers@me.com</a>&gt; wrote:</div><div><div style="word-wrap:break-word"><br>In addition I think that simply adding a constraints annotation to the generic type is wrong. All examples that we have mentioned are just perfect examples in that the generic type defines the content. Let’s say we have a class like this:<br><br><font face="Courier New">public abstract class ConvertableInteger&lt;V&gt; {<br><br><span class="gmail-m_-5905314894175019287Apple-tab-span" style="white-space:pre-wrap">        </span>private int value;<br><br><span class="gmail-m_-5905314894175019287Apple-tab-span" style="white-space:pre-wrap">        </span>public void setValue(int value) { this.value = value; }<br><br><span class="gmail-m_-5905314894175019287Apple-tab-span" style="white-space:pre-wrap">        </span>public int getValue() { return value; }<br><br><span class="gmail-m_-5905314894175019287Apple-tab-span" style="white-space:pre-wrap">        </span>public abstract V getConvertedValue();<br>}</font><br><br>If you want to validate an instance of this class you normally want to validate the integer and not the converted value:<br><br><font face="Courier New">private ConvertableInteger&lt;@<wbr>Min(2_000_000) Date&gt; myValue;</font><br><br>Such an expression looks like if you want to validate a Date object. In this case the better solution would be something like this:<br><br><font face="Courier New">@Min(2_000_000)<br>private ConvertableInteger&lt;<wbr>Date&gt; myValue;</font></div></div></blockquote><blockquote type="cite"><div><div style="word-wrap:break-word"><br>And now we end in 2 different ways how we annotation value wrappers:<br><br><font face="Courier New">private CachableValue&lt;@<wbr>NotEmpty String&gt; myCachedValue;<br><br>@Min(2_000_000)<br>private ConvertableInteger&lt;<wbr>Date&gt; myIntegerValue;</font><br></div></div></blockquote><div><br></div></div><div>First off, your specific example does not work as is as the class is abstract. You would need an explicit subclass (e.g. DateConvertableInteger extends ConvertableInteger&lt;Date&gt;). And in that situation, The more natural BV approach would be to do this:</div><div><br></div><div>public class DateConvertableInteger extend ConvertableInteger&lt;Date&gt; {</div><div><br></div><div>    @Min(@2_000_000)</div><div>    public int getValue() { return value; }</div><div><br></div><div>    @NotEmpty</div><div>    public Date getConvertedValue(<wbr>);</div><div>}</div><div><br></div><div>class SomeClass {</div><div>    @Valid</div><div>    private StringConvertableInteger myValue;</div><div>}</div><div><br></div><div>== overriding constraint declarations</div><div><br></div><div>Now if you want a way to override the constraints of an embedded (@Valid) object (graph), then I think that is a different subject that we can try and address. JPA for example has the notion of @AttributeOverride. It is more complicated in the case of Bean Validation as we would need to override actual annotations. Not sure how to express that for now. Do we think that it is a valid and important requirement?</div><div><br></div><div>To clarify, here is what is required</div><div><br></div><div>public class Embeddable {</div><div>    @NotEmpty String foo;</div><div>}</div><div><br></div><div>public class Entity {</div><div>    @Valid @Override(path=“foo”, constraints=@Min(3)) // note that this is not valid Java syntax</div><div>    Embeddable embeddable;</div><div>}</div><div><br></div><div>== Constraint on non parameterized containers</div><div><br></div><div>That raises another question, the proposal allows to to three things:</div><div><br></div><div>- apply constraints on a type use generic declaration(*): Collection&lt;@NotEmpty String&gt; foo;</div><div>- apply constraints on specialized generic parameters (*): @Pattern(…) StringProperty prop; //where StringProperty extends Property&lt;String&gt;</div><div>- apply constraints on container with no generic: @Min(3) IntegerContainer prop; // where class IntegerContainer{ Integer value; } i.e. no generic</div><div><br></div><div>(*) I don’t know the actual proper names so sorry if I butchered notions</div><div><br></div><div>I am liking option 3 less and less and as far as I can remember, it does not rely on an explicitly identified use case. Who is wanting to support that usage, vs restrict the container feature to parameterized containers?</div><div><br></div>I’m not sure I was all that clear, so please ask any question if you have any doubt.<span class="gmail-HOEnZb"><font color="#888888"><div><br></div><div>Emmanuel</div></font></span></div><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></div></div>