groovy
  1. groovy
  2. GROOVY-4033

Stateful metaclass mixins are completely undocumented

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.7
    • Fix Version/s: 1.7.2, 1.8-beta-1
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      http://groovyland.wordpress.com/2008/07/09/groovy-dynamic-stateful-mixins/ is the only documentation... and it's wrong.

      It's "owner", not "mixinOwner".

        Activity

        Hide
        Paul King added a comment -

        corrected URL to point to article mentioning erroneous 'mixinOwner'

        Show
        Paul King added a comment - corrected URL to point to article mentioning erroneous 'mixinOwner'
        Hide
        Paul King added a comment -

        currently the best "doco" is the unit test: groovy.lang.MixinTest

        Show
        Paul King added a comment - currently the best "doco" is the unit test: groovy.lang.MixinTest
        Hide
        Paul King added a comment -

        Here is the currently supported version of that example:

        class NoDuplicateCollection {
            void put (def obj) {
                def clone = find { it == obj }
                if (!clone) add obj
            }
        }
        
        def list = new Object()
        list.metaClass.mixin NoDuplicateCollection, LinkedList
        [1, 1, 2, 3, 2, 3].each{ list.put it }
        assert list.size() == 3
        assert list == [1, 2, 3]
        

        Also, if you are in a position to look at trunk (or a CI server)
        can you check the latest JavaDoc for EMC and see if that looks like
        it covers everything for mixins. Thanks.

        Show
        Paul King added a comment - Here is the currently supported version of that example: class NoDuplicateCollection { void put (def obj) { def clone = find { it == obj } if (!clone) add obj } } def list = new Object () list.metaClass.mixin NoDuplicateCollection, LinkedList [1, 1, 2, 3, 2, 3].each{ list.put it } assert list.size() == 3 assert list == [1, 2, 3] Also, if you are in a position to look at trunk (or a CI server) can you check the latest JavaDoc for EMC and see if that looks like it covers everything for mixins. Thanks.
        Hide
        Paul King added a comment -

        Any chance to look at the javadoc? Ok to close this issue? Thanks.

        Show
        Paul King added a comment - Any chance to look at the javadoc? Ok to close this issue? Thanks.
        Hide
        Paul King added a comment -

        No further comments - resolving.

        Show
        Paul King added a comment - No further comments - resolving.

          People

          • Assignee:
            Paul King
            Reporter:
            Luke Daley
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: