groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Schalk Cronjé <ysb...@gmail.com>
Subject Re: respondsTo and constructors
Date Tue, 05 May 2015 17:41:44 GMT
I did this for the time being. It works, but I'm not happy about it.

https://github.com/ysb33r/gradleTest/blob/master/src/main/groovy/org/ysb33r/gradle/gradletest/internal/Unpacker.groovy#L37

Lines 37-43.

On 03/05/2015 15:56, Dinko Srkoč wrote:
> On 1 May 2015 at 16:48, Schalk Cronjé <ysb33r@gmail.com> wrote:
>> I cannot figure out how to check for a constructor using respondsTo. If I
>> had the following
>>
>> class ABC {
>>    ABC(String s, File f) {}
>> }
>>
>> How can I use respondsTo to see if the constructor exists?
> It appears that you cannot. There's a
> `MetaClassImpl#retrieveConstructor(Class[])` that may help, or one can
> always fallback to Java reflection API.
>
> Cheers,
> Dinko
>
>> --
>> Schalk W. Cronjé
>> Twitter / Ello / Toeter : @ysb33r


-- 
Schalk W. Cronjé
Twitter / Ello / Toeter : @ysb33r


Mime
View raw message