       else throw new Error "unknown field #{field} on custom object object"
 
 class Field
+  finishBuild: ->
+    @defaultValue = @type.cast @defaultValue if @defaultValue
   set: (field, value, tag) ->
     switch field
     # required


class Type
  constructor: (@value) ->

class Picklist
  constructor: (tag) ->

    thing = new Builder()
    tag.getchildren().forEach (child) ->
      thing.set child.tag, child.text, child
    thing.finishBuild() if thing.finishBuild
    thing

factory = new Factory()
