Author Login
Post Reply
Hello,
I'd like to announce the release of MetaBuilder, a builder that builds
builders.
To learn more, please visit: http://groovytools.sourceforge.net/builder.
Here is a very quick example:
Say you have the following classes:
class Invoice {
def date
def items = []
}
class Item {
def upc
def qty
def price
}
Here is how to MetaBuilder how to build Invoices:
import groovytools.builder.*
def mb = new MetaBuilder()
def invoiceSchema = mb.define {
invoice (factory: Invoice) {
properties {
date()
}
collections {
items {
item (factory: Item) {
properties {
upc()
price()
qty()
}
}
}
}
}
}
Finally, here is how to actually build an Invoice:
def anInvoice = mb.build {
invoice(date: new Date()) {
items {
item(upc: 123, qty: 1, price: 14.99)
item(upe: 234, qty: 4, price: 14.99)
item(upc: 345, qty: 6, price: 14.99)
}
}
}
assert(anInvoice instanceof Invoice)
Enjoy!
didge
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email