[forge-dev] Roaster - Missing or improving ?

Antonio Goncalves antonio.mailing at gmail.com
Sat Apr 26 00:28:30 EDT 2014


I had created two JIRAs for that :

https://issues.jboss.org/browse/ROASTER-4
https://issues.jboss.org/browse/ROASTER-5 (looks like this one is done)


2014-04-21 21:22 GMT+02:00 Lincoln Baxter, III <lincolnbaxter at gmail.com>:

> Hey Antonio,
>
> I'm relatively certain that we don't support Generic types on method
> parameters yet, but we do support them on Types and Methods themselves via
> the GenericCapableSource interface.
>
> Looks like we need to add this to Parameters. Could you add a feature
> request for this? Thanks!
>
> ~Lincoln
>
>
> On Sun, Mar 30, 2014 at 1:05 PM, Antonio Goncalves <
> antonio.mailing at gmail.com> wrote:
>
>> Hi,
>>
>> Still playing with Roaster so I could fix
>> https://issues.jboss.org/browse/FORGE-1618 (Command
>> constraint-new-validator to create a new validator implementation). I don't
>> know how to do two things (nicely) :
>>
>> *# Parameterize interface*
>>
>> For a constraint, I need to implement a parametrize interface like this :
>>
>> public class MaxValidatorForString implements ConstraintValidator<Max,
>> Number> {
>>
>>
>> The only way I could find is passing a String :
>>
>> final JavaClassSource javaClass = Roaster.*create*(JavaClassSource.class
>> );
>> javaClass.setName("MaxValidatorForString");
>> javaClass.addImport(ConstraintValidator.class);
>> javaClass.addInterface("ConstraintValidator<Max, Number>");
>>
>> It's a shame because with addInterface(Class), it does the import
>> automatically and things are more typed. But I cannot add types :
>>
>> final JavaClassSource javaClass = Roaster.*create*(JavaClassSource.class
>> );
>> javaClass.setName("MaxValidatorForString");
>> javaClass.addInterface(ConstraintValidator.class);
>>
>> It would be good to have something like :
>>
>> javaClass.addInterface(ConstraintValidator.class).
>> addType(Max.class).addType(Number.class);
>>
>> *# Typed parameters*
>>
>> My isValid method takes two parameters. And the only way to add two
>> parameters seems to be by a String
>>
>> javaClass.addMethod().setPublic().setName("isValid").setReturnType(
>> "boolean").setParameters("Number value, ConstraintValidatorContext
>> context").setBody("return false;").addAnnotation(Override.class);
>>
>> Again, it would be nice to have typed parameters so the import is
>> implicit, and things are a bit more typed :
>>
>> javaClass.addMethod().setPublic().setName("isValid").setReturnType(
>> "boolean").addParameter(Number.class,
>> "value").addParameter(ConstraintValidatorContext.class, "context")
>> .setBody("return false;").addAnnotation(Override.class);
>>
>>
>> So I'm just wondering if I'm missing something or this is not implemented
>> yet on Roaster
>>
>> --
>> Antonio Goncalves
>> Software architect and Java Champion
>>
>> Web site <http://www.antoniogoncalves.org/> | Twitter<http://twitter.com/agoncal>
>>  | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris JUG<http://www.parisjug.org/>
>>  | Devoxx France <http://www.devoxx.fr/>
>>
>> _______________________________________________
>> forge-dev mailing list
>> forge-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>
>
>
>
> --
> Lincoln Baxter, III
> http://ocpsoft.org
> "Simpler is better."
>
> _______________________________________________
> forge-dev mailing list
> forge-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/forge-dev
>



-- 
Antonio Goncalves
Software architect and Java Champion

Web site <http://www.antoniogoncalves.org/> |
Twitter<http://twitter.com/agoncal>
 | LinkedIn <http://www.linkedin.com/in/agoncal> | Paris
JUG<http://www.parisjug.org/>
 | Devoxx France <http://www.devoxx.fr/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/forge-dev/attachments/20140426/a098f56a/attachment.html 


More information about the forge-dev mailing list