I don't have any strong opinion. I slightly tend to like the existing
syntax which avoids some of the visual ugliness if one group rule is
defined but that's only a small advantage.
Emmanuel
On Thu 2012-11-22 16:45, Gunnar Morling wrote:
Hi all,
I'm looking for some input on an idea I got regarding group translation.
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's what we have right now:
public class User {
@Valid
@ConvertGroup(from = Default.class, to = BasicContact.class)
private final Contact contact = new Contact();
}
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:
@Valid(conversions=
@ConvertGroup(from = Default.class, to = BasicContact.class
)
private final Contact contact = new Contact();
This would still allow to reuse the annotation, but avoids situations where
@ConvertGroup is given without @Valid. It also makes very clear what's
subject of the conversion (which might not be that obvious if the given
element hosts some more annotations).
On the down-side the "inner" annotation syntax is not that elegant,
although it's actually shorter when specifying multiple conversions:
@Valid(conversions={
@ConvertGroup(from = Default.class, to = BasicContact.class),
@ConvertGroup(from = Full.class, to = FullContact.class)
})
private final Contact contact = new Contact();
vs.
@Valid
@ConvertGroup.List({
@ConvertGroup(from = Default.class, to = BasicContact.class),
@ConvertGroup(from = Full.class, to = FullContact.class)
})
private final Contact contact = new Contact();
This could be further mitigated by naming the attribute "value", although
I'm a bit shy of allocating that default attribute.
If we already discussed (and rejected) this particular approach, please
ignore this mail, otherwise any feedback is appreciated :)
--Gunnar
[1]
https://hibernate.onjira.com/browse/BVAL-208
_______________________________________________
beanvalidation-dev mailing list
beanvalidation-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/beanvalidation-dev