<div dir="ltr">Yes, that looks nice. With TAB completion it will even make it easier : <div><br></div><div>java-new-method --body <PRESS TAB> (and the completion will show """)</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2014-06-28 6:33 GMT+02:00 Robert Balent <span dir="ltr"><<a href="mailto:robert@balent.cz" target="_blank">robert@balent.cz</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It definitely looks better without escaping but question is how do<br>
distinguish between char and String literal of size 1? Other<br>
possibility which comes to my mind is to add to the forge some<br>
special sequence which will disable parsing for the part of the text<br>
so we could have for example special sequence like this """ and the<br>
command would look like this:<br>
<div class=""><br>
java-new-method --return String.class --parameters "String s, boolean<br>
b, List<Integer> numbers" --body """String msg; if<br>
(s.equals("withinSimpleQuote") { msg="singleQuote"; return msg; })"""<br>
<br>
</div>Robert<br>
<br>
<br>
2014-06-27 14:47 GMT-07:00 Antonio Goncalves <<a href="mailto:antonio.mailing@gmail.com">antonio.mailing@gmail.com</a>>:<br>
<div class="HOEnZb"><div class="h5">> Hum.... escaping doesn't look nice. And what about using simple quote ? What<br>
> about :<br>
><br>
> java-add-annotation --annotation "TestAnnotation(param1 = 'str1', 'str2'},<br>
> param2 = 'hello', param3 = {String.class, Main.class}, param4 = ENUM_VAL,<br>
> param5<br>
> {ENUM_VAL_1,ENUM_VAL_2,ENUM_VAL_3})"<br>
><br>
> Would that be bad ? Any gotchas ? I hope one day we will be able to add<br>
> method bodies in Forge, and escaping will not help in readabilty. Something<br>
> like :<br>
><br>
> java-new-method --return String.class --parameters "String s, boolean b,<br>
> List<Integer> numbers" --body "String msg; if (s.equals('withinSimpleQuote')<br>
> { msg='singleQuote'; return msg; })"<br>
><br>
> If escaping is used, then we will have :<br>
><br>
> java-new-method --return String.class --parameters "String s, boolean b,<br>
> List<Integer> numbers" --body "String msg; if<br>
> (s.equals(\"withinSimpleQuote\") { msg=\"singleQuote\"; return msg; })"<br>
><br>
> It just doesn't look nice... But I suppose it's clearer for Java developpers<br>
> who are used to it.... hum.... dilema....<br>
><br>
> Antonio<br>
><br>
><br>
><br>
> 2014-06-27 9:45 GMT+02:00 Robert Balent <<a href="mailto:robert@balent.cz">robert@balent.cz</a>>:<br>
><br>
>> Hi,<br>
>><br>
>> I've added test and code for handling exceptions. Parameters should be<br>
>> working now. For example this works OK:<br>
>><br>
>> java-add-annotation --annotation "TestAnnotation(param1 =<br>
>> {\"str1\", \"str2\"}, param2 = \"hello\", param3 = {String.class,<br>
>> Main.class}, param4 = ENUM_VAL, param5 =<br>
>> {ENUM_VAL_1,ENUM_VAL_2,ENUM_VAL_3})"<br>
>><br>
>> Code doesn't look that good, it will probably need a little<br>
>> refactoring. I'll be happy if you comment about what could be<br>
>> improved.<br>
>><br>
>> Best,<br>
>> Robert<br>
>><br>
>><br>
>> 2014-06-26 20:54 GMT-07:00 Robert Balent <<a href="mailto:robert@balent.cz">robert@balent.cz</a>>:<br>
>> > I'm using "Roaster.parse" method for parsing so if it's not parsed<br>
>> > correctly, it will throw exception. I'll add exception handling and<br>
>> > tests today.<br>
>> ><br>
>> > 2014-06-26 12:10 GMT-07:00 Lincoln Baxter, III<br>
>> > <<a href="mailto:lincolnbaxter@gmail.com">lincolnbaxter@gmail.com</a>>:<br>
>> >> Hey Robert, this is excellent! Do you think you could add a test for<br>
>> >> this<br>
>> >> advanced "escaped/complex" parsing?<br>
>> >><br>
>> >> Thanks!<br>
>> >><br>
>> >><br>
>> >> On Thu, Jun 26, 2014 at 3:18 AM, Robert Balent <<a href="mailto:robert@balent.cz">robert@balent.cz</a>><br>
>> >> wrote:<br>
>> >>><br>
>> >>> Parse input as java code is good idea. However parentheses have to be<br>
>> >>> escaped in Forge shell.<br>
>> >>><br>
>> >>> Have look at pull request 474 [1]. I've tried to implement this and if<br>
>> >>> the input is correctly escaped, it should be working.<br>
>> >>><br>
>> >>> Example:<br>
>> >>><br>
>> >>> java-add-annotation --annotation javax.inject.Named(\"beanName\")<br>
>> >>><br>
>> >>><br>
>> >>> Also more complicated examples like this are working:<br>
>> >>><br>
>> >>> java-add-annotation --annotation "TestAnnotation(param1 = {\"str1\",<br>
>> >>> \"str2\"}, param2 = \"hello\", param3 = {String.class, Main.class},<br>
>> >>> param4 = ENUM_VAL)"<br>
>> >>><br>
>> >>><br>
>> >>> Cheers,<br>
>> >>><br>
>> >>> Robert<br>
>> >>><br>
>> >>><br>
>> >>> [1] <a href="https://github.com/forge/core/pull/474" target="_blank">https://github.com/forge/core/pull/474</a><br>
>> >>><br>
>> >>><br>
>> >>><br>
>> >>> 2014-06-24 22:40 GMT-07:00 Lincoln Baxter, III<br>
>> >>> <<a href="mailto:lincolnbaxter@gmail.com">lincolnbaxter@gmail.com</a>>:<br>
>> >>> > I think maybe we need to separate the parameters out in this case:<br>
>> >>> ><br>
>> >>> > ejb-new-bean --beanName foo --typeName FooBar<br>
>> >>> ><br>
>> >>> > We should decide what these parameters need to be called.<br>
>> >>> ><br>
>> >>> > In addition, I'm fine with the java-add-anotation command as well :)<br>
>> >>> > It<br>
>> >>> > could probably even accept full java code:<br>
>> >>> ><br>
>> >>> > java-add-annotation javax.inject.Named("beanName") --target .....<br>
>> >>> ><br>
>> >>> ><br>
>> >>> > On Sun, Jun 15, 2014 at 4:41 PM, Antonio Goncalves<br>
>> >>> > <<a href="mailto:antonio.mailing@gmail.com">antonio.mailing@gmail.com</a>> wrote:<br>
>> >>> >><br>
>> >>> >> Here is the JIRA : <a href="https://issues.jboss.org/browse/FORGE-1880" target="_blank">https://issues.jboss.org/browse/FORGE-1880</a><br>
>> >>> >> (Being<br>
>> >>> >> able<br>
>> >>> >> to add @Named to an EJBs... or any annotation anywhere)<br>
>> >>> >><br>
>> >>> >> I've linked it to <a href="https://issues.jboss.org/browse/FORGE-1838" target="_blank">https://issues.jboss.org/browse/FORGE-1838</a> (Being<br>
>> >>> >> able<br>
>> >>> >> to generate methods) because at the end of the day, the idea behind<br>
>> >>> >> both<br>
>> >>> >> JIRAs is being able to add Java artifacts (attributes, annotations,<br>
>> >>> >> methods...) to any kind of component (entity, backing bean, rest<br>
>> >>> >> endpoint...)<br>
>> >>> >><br>
>> >>> >><br>
>> >>> >> 2014-06-13 16:00 GMT+02:00 George Gastaldi <<a href="mailto:ggastald@redhat.com">ggastald@redhat.com</a>>:<br>
>> >>> >><br>
>> >>> >>> +1, is there a JIRA already for this?<br>
>> >>> >>><br>
>> >>> >>> Em 13/06/2014, às 10:51, "Ivan St. Ivanov"<br>
>> >>> >>> <<a href="mailto:ivan.st.ivanov@gmail.com">ivan.st.ivanov@gmail.com</a>><br>
>> >>> >>> escreveu:<br>
>> >>> >>><br>
>> >>> >>> Hi folks!<br>
>> >>> >>><br>
>> >>> >>> I think that java-add-annotation is a good command that we should<br>
>> >>> >>> have.<br>
>> >>> >>> But still it would be better to have also something more explicit<br>
>> >>> >>> for<br>
>> >>> >>> creating named beans and setting stereotypes. So, I think that the<br>
>> >>> >>> three<br>
>> >>> >>> levels of abstraction that Antonio described may be implemented.<br>
>> >>> >>> Well,<br>
>> >>> >>> at<br>
>> >>> >>> the end they will reuse one and the same code for adding<br>
>> >>> >>> annotation,<br>
>> >>> >>> so no<br>
>> >>> >>> repeating ourselves will occur.<br>
>> >>> >>><br>
>> >>> >>> Cheers,<br>
>> >>> >>> Ivan<br>
>> >>> >>><br>
>> >>> >>><br>
>> >>> >>> On Fri, Jun 13, 2014 at 4:39 PM, George Gastaldi<br>
>> >>> >>> <<a href="mailto:ggastald@redhat.com">ggastald@redhat.com</a>><br>
>> >>> >>> wrote:<br>
>> >>> >>>><br>
>> >>> >>>> I am leaning towards the java-add-annotation approach as it seems<br>
>> >>> >>>> more<br>
>> >>> >>>> intuitive and could solve other use cases that may arise.<br>
>> >>> >>>><br>
>> >>> >>>> Em 13/06/2014, às 04:19, Antonio Goncalves<br>
>> >>> >>>> <<a href="mailto:antonio.mailing@gmail.com">antonio.mailing@gmail.com</a>><br>
>> >>> >>>> escreveu:<br>
>> >>> >>>><br>
>> >>> >>>> When I create an EJB with Forge with the following command :<br>
>> >>> >>>><br>
>> >>> >>>> ejb-new-bean --named MyService<br>
>> >>> >>>><br>
>> >>> >>>> I get the following :<br>
>> >>> >>>><br>
>> >>> >>>> @Stateless<br>
>> >>> >>>> @LocalBean<br>
>> >>> >>>> public class MyService implements Serializable<br>
>> >>> >>>><br>
>> >>> >>>> In some cases, I would need to add an extra @Named annotation.<br>
>> >>> >>>> Several<br>
>> >>> >>>> ways to do it. On the EJB command itself, we could add a<br>
>> >>> >>>> parameter :<br>
>> >>> >>>><br>
>> >>> >>>> ejb-new-bean --named MyService --addNamed<br>
>> >>> >>>><br>
>> >>> >>>> But I think it would be good to have something more generic that<br>
>> >>> >>>> could<br>
>> >>> >>>> be used anywhere. We could use the same logic as constraint-add<br>
>> >>> >>>> (that<br>
>> >>> >>>> adds<br>
>> >>> >>>> any kind of constraint on any Entity) and have something like<br>
>> >>> >>>><br>
>> >>> >>>> cdi-add-qualifier --qualifier Named --target<br>
>> >>> >>>> org.app.service.MyService<br>
>> >>> >>>> // or on a property, which could be useful<br>
>> >>> >>>> cdi-add-qualifier --qualifier Named --onProperty myProp<br>
>> >>> >>>> cdi-add-qualifier --qualifier Named --onMethod myMethod<br>
>> >>> >>>><br>
>> >>> >>>> Or something even more generic would be to use the Java command<br>
>> >>> >>>><br>
>> >>> >>>> java-add-annotation --annotation javax.inject.Named --target<br>
>> >>> >>>> org.app.service.MyService<br>
>> >>> >>>> java-add-annotation --annotation javax.inject.Named --target<br>
>> >>> >>>> org.app.service.MyService --onProperty myProp<br>
>> >>> >>>> java-add-annotation --annotation javax.inject.Named --target<br>
>> >>> >>>> org.app.service.MyService --onMethod myMethod<br>
>> >>> >>>> java-add-annotation --annotation javax.inject.Named --onProperty<br>
>> >>> >>>> myProp<br>
>> >>> >>>> java-add-annotation --annotation javax.inject.Named --onMethod<br>
>> >>> >>>> myMethod<br>
>> >>> >>>><br>
>> >>> >>>> Any thoughts ?<br>
>> >>> >>>><br>
>> >>> >>>> Antonio<br>
>> >>> >>>><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>
>> >>> >>>><br>
>> >>> >>>><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>
>> >>> >>><br>
>> >>> >>><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>
>> >>> >>><br>
>> >>> >>><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>
>> >>> >><br>
>> >>> >><br>
>> >>> >><br>
>> >>> >><br>
>> >>> >> --<br>
>> >>> >> Antonio Goncalves<br>
>> >>> >> Software architect and Java Champion<br>
>> >>> >><br>
>> >>> >> Web site | Twitter | LinkedIn | Paris JUG | Devoxx France<br>
>> >>> >><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>
>> >>> ><br>
>> >>> ><br>
>> >>> ><br>
>> >>> ><br>
>> >>> > --<br>
>> >>> > Lincoln Baxter, III<br>
>> >>> > <a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a><br>
>> >>> > "Simpler is better."<br>
>> >>> ><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>
>> >>><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>
>> >><br>
>> >><br>
>> >><br>
>> >><br>
>> >> --<br>
>> >> Lincoln Baxter, III<br>
>> >> <a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a><br>
>> >> "Simpler is better."<br>
>> >><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>
>><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>
><br>
><br>
><br>
><br>
> --<br>
> Antonio Goncalves<br>
> Software architect and Java Champion<br>
><br>
> Web site | Twitter | LinkedIn | Paris JUG | Devoxx France<br>
><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>
<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></div></div></blockquote></div><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>