groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From frenchy48 <bam...@in2p3.fr>
Subject Re: aliasing methods
Date Wed, 13 Apr 2016 12:10:37 GMT
missing the code parts ? sorry ....
ok I try again

----------------------------------------------------
// this part read from a resource so simplifying
String className = 'java.awt.Canvas'
String originalMethodName = 'repaint'
String newMethName = 'repeindre'
Class clazz = Class.forName(className)
// now I want Canvas#repaint aliased as 'repeindre'
clazz.metaClass."$newMethName" = { it== null? delegate."$originalMethName"()
                                                                   
:delegate."$originalMethName"(*it)}
-------------------------------------------------------------------------

now the aliasing expression does not work properly
is there something simple or do I have to explore all the different cases
for the method argument?

for example this does not work:
-----------------------------------------------------
clazz.metaClass."$newMethName"  = clazz.metaClass.&"$originalMethName" 
------------------------------------------------------

thanks





-----
member of Grumpy Old Programmers
--
View this message in context: http://groovy.329449.n5.nabble.com/aliasing-methods-tp5732316p5732335.html
Sent from the Groovy Users mailing list archive at Nabble.com.

Mime
View raw message