File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Modular Closures for Builders (FactoryBuilderSupport)

 
John Dee
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic