Skip to content

Instantly share code, notes, and snippets.

@FriendlyTester
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FriendlyTester/ce3f55a9595b2bd2ec99 to your computer and use it in GitHub Desktop.
Save FriendlyTester/ce3f55a9595b2bd2ec99 to your computer and use it in GitHub Desktop.
AndrewGist
public class UserBuilder
{
private User;
public UserBuilder()
{
User = new User();
user.setFirstName("Richard");
user.setSurname("Bradshaw");
user.setAge(29);
user.setEmailAddress("richard@richard.com");
}
public User buildGenericUser()
{
return User;
}
public User buildOAPUser()
{
user.setAge(66);
return User;
}
public User buildTeenageUser()
{
user.setAge(66);
return User;
}
}
@tooming
Copy link

tooming commented Jun 26, 2015

I would "return this;" in User class methods, so you could build the data object like this:
user
.setFirstName("Richard")
.setSurName("Bradshaw")
.setAge(29);

Looks cleaner in my point of view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment