You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Pascal Schumacher (JIRA)" <ji...@apache.org> on 2015/07/13 20:40:05 UTC
[jira] [Closed] (GROOVY-5298) Easy way to access mixins
[ https://issues.apache.org/jira/browse/GROOVY-5298?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pascal Schumacher closed GROOVY-5298.
-------------------------------------
Resolution: Won't Fix
Fix Version/s: (was: 3.0)
Closing as won't fix because of Cédrics comment-
> Easy way to access mixins
> -------------------------
>
> Key: GROOVY-5298
> URL: https://issues.apache.org/jira/browse/GROOVY-5298
> Project: Groovy
> Issue Type: New Feature
> Components: groovy-jdk
> Affects Versions: 2.0-beta-2
> Environment: All
> Reporter: Venkat Srinivasan
> Labels: mixin
>
> When we add mixins to a class, the mixins are available through the mixedIn property. We can access a particular mixin by using, for example
> {code}
> mixedIn[ClassA].foo()
> {code}
> This works well if we know what mixins are part of the class.
> There are times when we want to be able to
> (a) get a list of mixins, and
> (b) be able to get a mixin one before the current mixin.
> For example, something like
> {{mixedIn.getPrevious(ClassA)}} would be very useful for method chaining purposes.
> Right now, I had to do the following to get to this (if there is a simpler way and I simply don't know it, please correct me):
> {code}
> def invokeOnPreviousMixin(MetaClass currentMixinMetaClass, String method, Object[] args) {
> def previousMixin = getClass()
> for(mixin in mixedIn.mixinClasses) { //Accessing private variable here
> if(mixin.mixinClass.theClass == currentMixinMetaClass.delegate.theClass) break
> previousMixin = mixin.mixinClass.theClass
> }
> mixedIn[previousMixin]."$method"(*args)
> }
> {code}
> Thanks.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)