Hi all,<br><br>I&#39;m looking for some input on an idea I got regarding group translation. <br><br>When discussing the issue [1] we agreed that the groups to be converted should be specified with a new annotation instead of directly within @Valid. So that&#39;s what we have right now:<br>
<br>public class User {<br><br>  @Valid<div>  @ConvertGroup(from = Default.class, to = BasicContact.class)<br>  private final Contact contact = new Contact();<br>}<br><br>IIRC the primary reason was that this new annotation could be re-used in other places. IMO having a separate annotation is the right way, but WDYT about specifying this annotation within instead of next to @Valid:</div>
<div><br></div><div>  @Valid(conversions=</div><div>    @ConvertGroup(from = Default.class, to = BasicContact.class<div>  )<br>  private final Contact contact = new Contact();</div></div><div><br></div><div>This would still allow to reuse the annotation, but avoids situations where @ConvertGroup is given without @Valid. It also makes very clear what&#39;s subject of the conversion (which might not be that obvious if the given element hosts some more annotations).</div>
<div><br></div><div>On the down-side the &quot;inner&quot; annotation syntax is not that elegant, although it&#39;s actually shorter when specifying multiple conversions:</div><div><br></div><div>  @Valid(conversions={<br>
</div><div><div>    @ConvertGroup(from = Default.class, to = BasicContact.class),</div><div>    @ConvertGroup(from = Full.class, to = FullContact.class)</div><div>  })</div><div><div>  private final Contact contact = new Contact();</div>
</div></div><div><br></div><div>vs.</div><div><br></div><div><div>  @Valid</div><div>  @ConvertGroup.List({<br>    @ConvertGroup(from = Default.class, to = BasicContact.class),</div><div>    @ConvertGroup(from = Full.class, to = FullContact.class)</div>
<div>  })<br>  private final Contact contact = new Contact();<br></div></div><div><br></div><div>This could be further mitigated by naming the attribute &quot;value&quot;, although I&#39;m a bit shy of allocating that default attribute.<br>
</div><div><br></div><div>If we already discussed (and rejected) this particular approach, please ignore this mail, otherwise any feedback is appreciated :)<br></div><div><br></div><div>--Gunnar<br><br>[1] <a href="https://hibernate.onjira.com/browse/BVAL-208">https://hibernate.onjira.com/browse/BVAL-208</a><br>
</div><div><br></div>