Last active
May 6, 2020 11:15
-
-
Save kaibeedevadmin/a246c55201133645de2003b3394fe9d3 to your computer and use it in GitHub Desktop.
This file contains 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
public class UserFactory { | |
private UserRepository userRepository; | |
public UserFactory(UserRepository userRepository) { | |
this.userRepository = userRepository; | |
} | |
public User createUser(UserInfo userInfo) { | |
if (isEmailInvalid(userInfo.getEmail())) { | |
throw new InvalidUserEmailException(); | |
} | |
return userRepository.save(mapToUser(userInfo)); | |
} | |
private boolean isEmailInvalid(String userInfo) { | |
// Fake method for example only | |
return false; | |
} | |
private User mapToUser(UserInfo userInfo) { | |
// Fake method for example only | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment