[ 
https://issues.apache.org/jira/browse/VELOCITY-892?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16653786#comment-16653786
 ] 

Thomas Mortagne edited comment on VELOCITY-892 at 10/17/18 4:29 PM:
--------------------------------------------------------------------

Actually my plan was to implement a ConversionHandler and not add a set of 
converters since XWiki already have a conversion system which is used in 
https://github.com/xwiki/xwiki-commons/blob/master/xwiki-commons-core/xwiki-commons-velocity/src/main/java/org/xwiki/velocity/introspection/MethodArgumentsUberspector.java
 for example. So my issue is more with #getNeededConverter being asked a Class 
instead of a Type.

Note that in our uberspector the logic is a bit different, if it does not find 
any matching method it directly try to convert the parameters for each method 
until it find one for which the conversion did not failed. For example even if 
there is a Converter available for Integer, the passed String might not 
actually be a number in which case the conversion will fail and it will try 
another method which expect some enum and this time it works fine. This is 
because our converter support really quite a lot of types which mean asking if 
a converter exist for a type does not give much information for the purpose of 
parameters conversion.


was (Author: tmortagne):
Actually my plan was to implement a ConversionHandler and not add a set of 
converters since XWiki already have a conversion system which is used in 
https://github.com/xwiki/xwiki-commons/blob/master/xwiki-commons-core/xwiki-commons-velocity/src/main/java/org/xwiki/velocity/introspection/MethodArgumentsUberspector.java
 for example. So my issue is more with #getNeededConverter being asked a Class 
instead of a Type.

> Method arguments conversions should be based on Type instead of Class
> ---------------------------------------------------------------------
>
>                 Key: VELOCITY-892
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-892
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 2.0
>            Reporter: Thomas Mortagne
>            Priority: Major
>             Fix For: 2.0
>
>
> I was happy to see that method arguments conversion has been added to 2.0 so 
> that I can remove the uberspector we have on XWiki side but unfortunately 
> ConversionHandler is limited to classes which is way too restrictive for us 
> (for example if the parameter type is List<String> it won't do the same thing 
> than if the type is List<Integer>).
> Our uberspector can be found on 
> https://github.com/xwiki/xwiki-commons/blob/master/xwiki-commons-core/xwiki-commons-velocity/src/main/java/org/xwiki/velocity/introspection/MethodArgumentsUberspector.java
>  to see what we do exactly.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org

Reply via email to