[xwiki-devs] Velocity uberspector to automatically convert String method arguments to Enum when possible
Hi devs, I just committed a new Velocity uberspector that automatically converts String method arguments to Enum when possible. Please review it and tell me if there's something wrong. The idea is to be able to call #someMethod(SomeEnum) with $obj.someMethod('VALUE') if SomeEnum.VALUE is a valid constant. See https://github.com/xwiki/xwiki-commons/commit/dbf1e06cc4f949c6f0b5a03c570671... . Thanks, Marius
Hi Marius, On May 15, 2012, at 7:54 PM, Marius Dumitru Florea wrote:
Hi devs,
I just committed a new Velocity uberspector that automatically converts String method arguments to Enum when possible. Please review it and tell me if there's something wrong.
Seems ok, can't find anything that wouldn't work for the moment :)
The idea is to be able to call #someMethod(SomeEnum) with
$obj.someMethod('VALUE')
What if I call #someMethod(String, SomeEnum) with $obj.someMethod(string, myEnum) Does it work? (same question with any number of arguments) If not then maybe it's a bit inconsistent and some users may not understand why it works and then suddenly fail to work in the following case: imagine that the method has one param initially (the enum) and a second param is added later on. Thanks -Vincent
if SomeEnum.VALUE is a valid constant.
See https://github.com/xwiki/xwiki-commons/commit/dbf1e06cc4f949c6f0b5a03c570671... .
Thanks, Marius
On May 15, 2012, at 8:28 PM, Vincent Massol wrote:
Hi Marius,
On May 15, 2012, at 7:54 PM, Marius Dumitru Florea wrote:
Hi devs,
I just committed a new Velocity uberspector that automatically converts String method arguments to Enum when possible. Please review it and tell me if there's something wrong.
Seems ok, can't find anything that wouldn't work for the moment :)
The idea is to be able to call #someMethod(SomeEnum) with
$obj.someMethod('VALUE')
What if I call #someMethod(String, SomeEnum)
with
$obj.someMethod(string, myEnum)
Does it work? (same question with any number of arguments)
If not then maybe it's a bit inconsistent and some users may not understand why it works and then suddenly fail to work in the following case: imagine that the method has one param initially (the enum) and a second param is added later on.
ok I've looked at the code now and it seems it's supported, so it's cool. Thanks -Vincent
Thanks -Vincent
if SomeEnum.VALUE is a valid constant.
See https://github.com/xwiki/xwiki-commons/commit/dbf1e06cc4f949c6f0b5a03c570671... .
Thanks, Marius
On Tue, May 15, 2012 at 9:29 PM, Vincent Massol <[email protected]> wrote:
On May 15, 2012, at 8:28 PM, Vincent Massol wrote:
Hi Marius,
On May 15, 2012, at 7:54 PM, Marius Dumitru Florea wrote:
Hi devs,
I just committed a new Velocity uberspector that automatically converts String method arguments to Enum when possible. Please review it and tell me if there's something wrong.
Seems ok, can't find anything that wouldn't work for the moment :)
The idea is to be able to call #someMethod(SomeEnum) with
$obj.someMethod('VALUE')
What if I call #someMethod(String, SomeEnum)
with
$obj.someMethod(string, myEnum)
Does it work? (same question with any number of arguments)
If not then maybe it's a bit inconsistent and some users may not understand why it works and then suddenly fail to work in the following case: imagine that the method has one param initially (the enum) and a second param is added later on.
ok I've looked at the code now and it seems it's supported, so it's cool.
Yes, it should work with any number of parameters. Now, if you have both #someMethod(String, String) #someMethod(String, SomeEnum) the first will be called because it will be found by the default Velocity introspector. But that's an edge case. Thanks, Marius
Thanks -Vincent
Thanks -Vincent
if SomeEnum.VALUE is a valid constant.
See https://github.com/xwiki/xwiki-commons/commit/dbf1e06cc4f949c6f0b5a03c570671... .
Thanks, Marius
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
participants (2)
-
Marius Dumitru Florea -
Vincent Massol