• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Modular Closures for Builders (FactoryBuilderSupport)

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following is an attempt to modularize my DSL files because
there is a nested closure that is identically defined in
many of these DSL files.


Current (working) Non-Modular Implementation

JAVA CODE:



patient.groovy



The above works, but the problem is that the entire closure drug(){...}
is used in many other DSL files.

So, what I would like to do is pull the drug(){...} closure out of patient.groovy and put it
into a new drugs.groovy. The following is what I modified the above to in order to modularize the
drug closure, but I'm not understanding part of it.



Modified (broken) Modular Implementation

Modified Java Code:



New drugs.groovy




Modified patient.groovy



I think things are breaking down in the new drugs() {...} closure. drugClosure is defined in
a separate file and I'm having a heck of a time trying to find information that explains how to
include/reference/inject that into patient {...}


Any help would be much appreciated.

Thanks,
John
 
John Dee
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found the solution:

The the builder class needs a new method I named as 'include(Closure c, Object args)' method within the builder.

BUILDER Class:



Modified patient.groovy

 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic