Last active
August 29, 2015 14:02
-
-
Save spikeheap/8c5891567462da43d02e to your computer and use it in GitHub Desktop.
Refactoring a traditional Java builder to use Groovy's map constructor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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