I like it, when values are set into attributes from where they have been fetched. Makes for readable code.
UserBean deputyChange = myTransferObject.getDeputy();
if (deputyChange != null && deputyChange.getUid() != null) {
if (!checkUserRole(deputyChange.getUid(), FunctionGroups.ROLE_TO_CHECK.getRole())) {
throw new IllegalArgumentException("Deputy user-id not valid: " + deputyChange.getUid());
}
myTransferObject.setDeputy(deputyChange);
myContext.getMyBean().getMyOtherTransferObject().setAssistanceUserDetail(deputyChange);
}
Apart from the fact that the webapplications user gets a nice looking Exception Message in his browser if he selected the wrong user from a list… It really makes sense to set the originating attribute to the value it delivered just a few lines above…