Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7957

Allow static compilation of builders that implement methodMissing / propertyMissing

    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: GEP
    • Labels:
      None

      Description

      Similar to Scala's Dynamic http://www.scala-lang.org/api/current/index.html#scala.Dynamic

      We should be able to write builders that are usable from statically compiled code. To achieve this I recommend the following:

      // if the object implements methodMissing dispatch to it
      foo.bar("blah")      ~~> foo.methodMissing("bar", "blah")
      // if the object implements propertyMissing dispatch to it
      foo.var1           ~~> foo.propertyMissing("var1")
      // if the object implements propertyMissing dispatch to it
      foo.var1 = 10      ~~> foo.propertyMissing("var1", 10)
      

      When combined with GROOVY-7956 it would then be possibly to fully implement builders that are compatible with @CompileStatic and certain existing builders could be enhanced to take advantage of this feature JsonBuilder, MarkupBuilder etc.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              graemerocher1 Graeme Rocher
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: