<div dir="ltr">Hey Antonio, <div><br></div><div>I don't really know how to do this off the top of my head. My guess is that you'll need to do what you've done for the prior elements and provide the definition using a String. Will this work until we can add this functionality to the API?</div>
<div><br></div><div>~Lincoln</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Mar 23, 2014 at 10:37 AM, Antonio Goncalves <span dir="ltr"><<a href="mailto:antonio.mailing@gmail.com" target="_blank">antonio.mailing@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">It's not like I have the choice. This is the way you model a constraint with Bean Validation : <a href="http://beanvalidation.org/1.1/spec/#constraintsdefinitionimplementation-multipleconstraints" target="_blank">http://beanvalidation.org/1.1/spec/#constraintsdefinitionimplementation-multipleconstraints</a></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">2014-03-22 9:11 GMT+01:00 Luca Masini <span dir="ltr"><<a href="mailto:luca.masini.mailing.list@gmail.com" target="_blank">luca.masini.mailing.list@gmail.com</a>></span>:<div>
<div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Why don't you model it like "NamedQueries/NamedQuery" ?</div><div class="gmail_extra"><br>
<br><div class="gmail_quote">2014-03-22 7:25 GMT+01:00 Antonio Goncalves <span dir="ltr"><<a href="mailto:antonio.mailing@gmail.com" target="_blank">antonio.mailing@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div class="gmail_extra">Hi,</div><div class="gmail_extra"><br></div><div class="gmail_extra">
This is a Roaster question. I've been trying to create a Bean Validation constraint properly... in vain. What I want to achieve is the following (notice the @List annotation) :</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">
<p><font face="courier new, monospace"><span>@Target</span>({<span><b><i>METHOD</i></b></span>, <span><b><i>FIELD</i></b></span>, <span><b><i>ANNOTATION_TYPE</i></b></span>, <span><b><i>CONSTRUCTOR</i></b></span>, <span><b><i>PARAMETER</i></b></span>})<br>
<span>@Retention</span>(<span><b><i>RUNTIME</i></b></span>)<br>
<span>@Documented<br></span><span>@Constraint</span>(validatedBy = {})<br>
<span><b>public </b></span>@<span><b>interface </b></span><span>Email </span>{<br>
<br>
String message() <span><b>default </b></span><span><b>"wrong email address"</b></span>;<br>
<br>
Class<?>[] groups() <span><b>default </b></span>{};<br>
<br>
Class<? <span><b>extends </b></span>Payload>[] payload() <span><b>default </b></span>{};<br>
<br>
<span>@Target</span>({<span><b><i>METHOD</i></b></span>, <span><b><i>FIELD</i></b></span>, <span><b><i>ANNOTATION_TYPE</i></b></span>, <span><b><i>CONSTRUCTOR</i></b></span>, <span><b><i>PARAMETER</i></b></span>})<br>
<span>@Retention</span>(<span><b><i>RUNTIME</i></b></span>)<br>
@<span><b>interface </b></span><span><font color="#ff0000"><b>List</b></font> </span>{<br>
<span>Email</span>[] value();<br>
}<br>
}<br>
</font></p><p><br></p><p>This is the code I've written. Both annotation are generated separately... but I don't know how to add <span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:11.818181991577148px;line-height:15.272726058959961px;white-space:pre-wrap">listAnnotation</span> inside <span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:11.818181991577148px;line-height:15.272726058959961px;white-space:pre-wrap">emailAnnotation</span>. Any idea ?</p>
<p>Thanks</p><p><br></p><pre style="line-height:15.272726058959961px;width:743.6363525390625px;font-size:11.818181991577148px;margin-bottom:0px;font-family:Consolas,'Liberation Mono',Courier,monospace;margin-top:0px;padding:0px">
<div><span style="font-weight:bold">public</span> <span style="font-weight:bold">class</span> <span style="color:rgb(68,85,136);font-weight:bold">Main</span> <span style="font-weight:bold">{</span></div>
<div> <span style="font-weight:bold">public</span> <span style="font-weight:bold">static</span> <span style="color:rgb(68,85,136);font-weight:bold">void</span> <span style="color:rgb(153,0,0);font-weight:bold">main</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">String</span><span style="font-weight:bold">[]</span> <span style="color:rgb(51,51,51)">args</span><span style="font-weight:bold">)</span> <span style="font-weight:bold">{</span></div>
<div> </div><div> <span style="color:rgb(153,153,136);font-style:italic">// This is the inner annotation List</span></div><div>
<span style="font-weight:bold">final</span> <span style="color:rgb(51,51,51)">JavaAnnotationSource</span> <span style="color:rgb(51,51,51)">listAnnotation</span> <span style="font-weight:bold">=</span> <span style="color:rgb(51,51,51)">Roaster</span><span style="font-weight:bold">.</span><span style="color:teal">create</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">JavaAnnotationSource</span><span style="font-weight:bold">.</span><span style="color:teal">class</span><span style="font-weight:bold">);</span></div>
<div> <span style="color:rgb(51,51,51)">listAnnotation</span><span style="font-weight:bold">.</span><span style="color:teal">setName</span><span style="font-weight:bold">(</span><span style="color:rgb(221,17,68)">"List"</span><span style="font-weight:bold">);</span></div>
<div> <span style="color:rgb(51,51,51)">listAnnotation</span><span style="font-weight:bold">.</span><span style="color:teal">addAnnotation</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">Retention</span><span style="font-weight:bold">.</span><span style="color:teal">class</span><span style="font-weight:bold">).</span><span style="color:teal">setEnumValue</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">RUNTIME</span><span style="font-weight:bold">);</span></div>
<div> <span style="color:rgb(51,51,51)">listAnnotation</span><span style="font-weight:bold">.</span><span style="color:teal">addAnnotation</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">Target</span><span style="font-weight:bold">.</span><span style="color:teal">class</span><span style="font-weight:bold">).</span><span style="color:teal">setEnumValue</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">METHOD</span><span style="font-weight:bold">,</span> <span style="color:rgb(51,51,51)">FIELD</span><span style="font-weight:bold">,</span> <span style="color:rgb(51,51,51)">PARAMETER</span><span style="font-weight:bold">,</span> <span style="color:rgb(51,51,51)">TYPE</span><span style="font-weight:bold">);</span></div>
<div> <span style="color:rgb(51,51,51)">listAnnotation</span><span style="font-weight:bold">.</span><span style="color:teal">addAnnotationElement</span><span style="font-weight:bold">(</span><span style="color:rgb(221,17,68)">"Email[] value()"</span><span style="font-weight:bold">);</span></div>
<div> <span style="color:rgb(51,51,51)">System</span><span style="font-weight:bold">.</span><span style="color:teal">out</span><span style="font-weight:bold">.</span><span style="color:teal">println</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">listAnnotation</span><span style="font-weight:bold">);</span></div>
<div> </div><div> <span style="color:rgb(153,153,136);font-style:italic">// This is the annotation @Email</span></div><div>
<span style="font-weight:bold">final</span> <span style="color:rgb(51,51,51)">JavaAnnotationSource</span> <span style="color:rgb(51,51,51)">emailAnnotation</span> <span style="font-weight:bold">=</span> <span style="color:rgb(51,51,51)">Roaster</span><span style="font-weight:bold">.</span><span style="color:teal">create</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">JavaAnnotationSource</span><span style="font-weight:bold">.</span><span style="color:teal">class</span><span style="font-weight:bold">);</span></div>
<div> <span style="color:rgb(51,51,51)">emailAnnotation</span><span style="font-weight:bold">.</span><span style="color:teal">setPackage</span><span style="font-weight:bold">(</span><span style="color:rgb(221,17,68)">"org.agoncal.proj.constraints"</span><span style="font-weight:bold">).</span><span style="color:teal">setName</span><span style="font-weight:bold">(</span><span style="color:rgb(221,17,68)">"Email"</span><span style="font-weight:bold">);</span></div>
<div> <span style="color:rgb(51,51,51)">emailAnnotation</span><span style="font-weight:bold">.</span><span style="color:teal">addImport</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">Payload</span><span style="font-weight:bold">.</span><span style="color:teal">class</span><span style="font-weight:bold">);</span></div>
<div> <span style="color:rgb(51,51,51)">emailAnnotation</span><span style="font-weight:bold">.</span><span style="color:teal">addAnnotation</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">Documented</span><span style="font-weight:bold">.</span><span style="color:teal">class</span><span style="font-weight:bold">);</span></div>
<div> <span style="color:rgb(51,51,51)">emailAnnotation</span><span style="font-weight:bold">.</span><span style="color:teal">addAnnotation</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">Retention</span><span style="font-weight:bold">.</span><span style="color:teal">class</span><span style="font-weight:bold">).</span><span style="color:teal">setEnumValue</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">RUNTIME</span><span style="font-weight:bold">);</span></div>
<div> <span style="color:rgb(51,51,51)">emailAnnotation</span><span style="font-weight:bold">.</span><span style="color:teal">addAnnotation</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">Target</span><span style="font-weight:bold">.</span><span style="color:teal">class</span><span style="font-weight:bold">).</span><span style="color:teal">setEnumValue</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">METHOD</span><span style="font-weight:bold">,</span> <span style="color:rgb(51,51,51)">FIELD</span><span style="font-weight:bold">,</span> <span style="color:rgb(51,51,51)">PARAMETER</span><span style="font-weight:bold">,</span> <span style="color:rgb(51,51,51)">TYPE</span><span style="font-weight:bold">);</span></div>
<div> <span style="color:rgb(51,51,51)">emailAnnotation</span><span style="font-weight:bold">.</span><span style="color:teal">addAnnotation</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">Constraint</span><span style="font-weight:bold">.</span><span style="color:teal">class</span><span style="font-weight:bold">).</span><span style="color:teal">setLiteralValue</span><span style="font-weight:bold">(</span><span style="color:rgb(221,17,68)">"validatedBy"</span><span style="font-weight:bold">,</span> <span style="color:rgb(221,17,68)">"{}"</span><span style="font-weight:bold">);</span></div>
<div> <span style="color:rgb(51,51,51)">emailAnnotation</span><span style="font-weight:bold">.</span><span style="color:teal">addAnnotationElement</span><span style="font-weight:bold">(</span><span style="color:rgb(221,17,68)">"String message() default \"wrong email address\""</span><span style="font-weight:bold">);</span></div>
<div> <span style="color:rgb(51,51,51)">emailAnnotation</span><span style="font-weight:bold">.</span><span style="color:teal">addAnnotationElement</span><span style="font-weight:bold">(</span><span style="color:rgb(221,17,68)">"Class<?>[] groups() default {}"</span><span style="font-weight:bold">);</span></div>
<div> <span style="color:rgb(51,51,51)">emailAnnotation</span><span style="font-weight:bold">.</span><span style="color:teal">addAnnotationElement</span><span style="font-weight:bold">(</span><span style="color:rgb(221,17,68)">"Class<? extends Payload>[] payload() default {}"</span><span style="font-weight:bold">);</span></div>
<div> </div><div> <span style="color:rgb(153,153,136);font-style:italic">// I was expecting to have a method like that so I could add annotation inside another one</span></div>
<div> <span style="color:rgb(153,153,136);font-style:italic">// emailAnnotation.addAnnotationElement(emailAnnotation);</span></div><div> </div>
<div> <span style="color:rgb(51,51,51)">System</span><span style="font-weight:bold">.</span><span style="color:teal">out</span><span style="font-weight:bold">.</span><span style="color:teal">println</span><span style="font-weight:bold">(</span><span style="color:rgb(51,51,51)">emailAnnotation</span><span style="font-weight:bold">);</span></div>
<div> </div><div> <span style="font-weight:bold">}</span></div><div> </div><div>
<span style="font-weight:bold">}</span></div></pre><span><font color="#888888"><p><br></p><br><div><br></div>-- <br>Antonio Goncalves <br>Software architect and Java Champion<br><br><a href="http://www.antoniogoncalves.org/" target="_blank">Web site</a> | <a href="http://twitter.com/agoncal" target="_blank">Twitter</a> | <a href="http://www.linkedin.com/in/agoncal" target="_blank">LinkedIn</a> | <a href="http://www.parisjug.org/" target="_blank">Paris JUG</a> | <a href="http://www.devoxx.fr/" target="_blank">Devoxx France</a>
</font></span></div></div>
<br></div></div>_______________________________________________<br>
forge-dev mailing list<br>
<a href="mailto:forge-dev@lists.jboss.org" target="_blank">forge-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><span><font color="#888888"><br></font></span></blockquote></div><span><font color="#888888"><br>
<br clear="all"><div><br></div>-- <br>****************************************<br>
<a href="http://www.lucamasini.net" target="_blank">http://www.lucamasini.net</a><br><a href="http://twitter.com/lmasini" target="_blank">http://twitter.com/lmasini</a><br><a href="http://www.linkedin.com/pub/luca-masini/7/10/2b9" target="_blank">http://www.linkedin.com/pub/luca-masini/7/10/2b9</a><br>
****************************************
</font></span></div>
<br>_______________________________________________<br>
forge-dev mailing list<br>
<a href="mailto:forge-dev@lists.jboss.org" target="_blank">forge-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br></blockquote></div></div></div><div><div class="h5"><br><br clear="all"><div><br></div>
-- <br>Antonio Goncalves <br>Software architect and Java Champion<br>
<br><a href="http://www.antoniogoncalves.org/" target="_blank">Web site</a> | <a href="http://twitter.com/agoncal" target="_blank">Twitter</a> | <a href="http://www.linkedin.com/in/agoncal" target="_blank">LinkedIn</a> | <a href="http://www.parisjug.org/" target="_blank">Paris JUG</a> | <a href="http://www.devoxx.fr/" target="_blank">Devoxx France</a>
</div></div></div>
<br>_______________________________________________<br>
forge-dev mailing list<br>
<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Lincoln Baxter, III<br><a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a><br>
"Simpler is better."
</div>