Skip to content

Instantly share code, notes, and snippets.

@uday-rayala
Created September 26, 2011 20:20
Show Gist options
  • Save uday-rayala/1243290 to your computer and use it in GitHub Desktop.
Save uday-rayala/1243290 to your computer and use it in GitHub Desktop.
Builder pattern standard
case class AuthorBuilder(familyName: String = "John",
givenNames: Seq[String] = Seq("Doe"),
books: Seq[String] = Seq(),
affiliations: Seq[String] = Seq()) {
def asXML =
<Author>
<FamilyName>{familyName}</FamilyName>
<GivenNames>
{for (name <- givenNames) yield <GivenName>{name}</GivenName>}
</GivenNames>
<Books>
{for (id <- books) yield <Book>{id}</Book>}
</Books>
<Affiliations>
{for (id <- affiliations) yield <Organisation>{id}</Organisation>}
</Affiliations>
</Author>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment