Source:
private User build(Client client) { User user = client.instantiate(User.class); user.setProfile(client.instantiate(UserProfile.class)); UserProfile userProfile = user.getProfile(); if (Strings.hasText(firstName)) userProfile.setFirstName(firstName); if (Strings.hasText(lastName)) userProfile.setLastName(lastName); if (Strings.hasText(email)) userProfile.setEmail(email); if (Strings.hasText(secondEmail)) userProfile.setSecondEmail(secondEmail); if (Strings.hasText(mobilePhone)) userProfile.setMobilePhone(mobilePhone); if (Strings.hasText(login)) { userProfile.setLogin(login); } else { userProfile.setLogin(email); } if (!Collections.isEmpty(groupIds)) { if (user instanceof AbstractResource) { ((AbstractResource) user).setProperty("groupIds", groupIds, true); } else { throw new IllegalArgumentException("'User' is not an instance of 'AbstractResource', so 'groupIds' cannot be set. This would only happen if the implementation of 'User' has been customized."); } } userProfile.putAll(customProfileAttributes); if (Strings.hasText(securityQuestion)) { RecoveryQuestionCredential question = client.instantiate(RecoveryQuestionCredential.class); question.setQuestion(securityQuestion); question.setAnswer(securityQuestionAnswer); createCredentialsIfNeeded(user, client).setRecoveryQuestion(question); } if (password != null && password.length > 0) { PasswordCredential passwordCredential = client.instantiate(PasswordCredential.class); createCredentialsIfNeeded(user, client).setPassword(passwordCredential.setValue(password)); } if (passwordHashProperties != null) { PasswordCredential passwordCredential = client.instantiate(PasswordCredential.class); passwordCredential.put("hash", passwordHashProperties); createCredentialsIfNeeded(user, client).setPassword(passwordCredential); } return user; }

Target:
private User build(Client client) { User user = client.instantiate(User.class); user.setProfile(client.instantiate(UserProfile.class)); UserProfile userProfile = user.getProfile(); if (Strings.hasText(firstName)) userProfile.setFirstName(firstName); if (Strings.hasText(lastName)) userProfile.setLastName(lastName); if (Strings.hasText(email)) userProfile.setEmail(email); if (Strings.hasText(secondEmail)) userProfile.setSecondEmail(secondEmail); if (Strings.hasText(mobilePhone)) userProfile.setMobilePhone(mobilePhone); if (Strings.hasText(login)) { userProfile.setLogin(login); } else { userProfile.setLogin(email); } if (!Collections.isEmpty(groupIds)) { if (user instanceof AbstractResource) { ((AbstractResource) user).setProperty("groupIds", groupIds, true); } else { throw new IllegalArgumentException("'User' is not an instance of 'AbstractResource', so 'groupIds' cannot be set. This would only happen if the implementation of 'User' has been customized."); } } userProfile.putAll(customProfileAttributes); if (Strings.hasText(securityQuestion)) { RecoveryQuestionCredential question = client.instantiate(RecoveryQuestionCredential.class); question.setQuestion(securityQuestion); question.setAnswer(securityQuestionAnswer); createCredentialsIfNeeded(user, client).setRecoveryQuestion(question); } if (password != null && password.length > 0) { if (passwordHashProperties != null) { throw new IllegalArgumentException("Cannot specify both password and password hash, use one or the other."); } PasswordCredential passwordCredential = client.instantiate(PasswordCredential.class); createCredentialsIfNeeded(user, client).setPassword(passwordCredential.setValue(password)); } if (passwordHashProperties != null) { PasswordCredential passwordCredential = client.instantiate(PasswordCredential.class); passwordCredential.put("hash", passwordHashProperties); createCredentialsIfNeeded(user, client).setPassword(passwordCredential); } return user; }