Skip to content

Instantly share code, notes, and snippets.

@spikeheap
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save spikeheap/8c5891567462da43d02e to your computer and use it in GitHub Desktop.

Select an option

Save spikeheap/8c5891567462da43d02e to your computer and use it in GitHub Desktop.
Refactoring a traditional Java builder to use Groovy's map constructor
// The following
def name = new com.mirth.results.models.NameModel()
name.setPrefix(it[4].toString())
name.setFirst(it[1].toString())
name.setMiddle(it[2].toString())
name.setLast(it[0].toString())
expectedPatient.setName(name)
// Can be written without .toString and using Groovy's map constructor!
expectedPatient.name = new com.mirth.results.models.NameModel(
prefix: it[4],
first: it[1],
middle: it[2],
last: it[0]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment