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 Thu, 14 Apr 2016 09:50:33 GMT
by the way doing this by changing the .properties file description with such
a protocol
-----------------------------
#properties file
java.awt.geom.Area#isEmpty() = estVide
 java.awt.geom.Area#contains = contient
-----------------------------
now this code does not work! 
the key name is parsed into className and methodName
clazz is the Class corresponding to methodName
------------------------------------------------------------------------
 if(methodName.endsWith("()")) {
                    methodName = methodName.replace("()","")
                    clazz.metaClass."$newMethodName" = { 
delegate."$methodName"() }
   } else {
                    clazz.metaClass."$newMethodName" = { it== null?
delegate."$methodName"(null)
                            :delegate."$methodName"(*it)}
    }
------------------------------------------------------------------
it does not work because if you invoke the translation of "contains" with
two double values
these are transformed in Doubles and the invocation fails!

so there should be a better idea ...



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

Mime
View raw message