Good afternoon , In userServiceImpl.checkPrivileges, i would like to flatten the for-if-hierarchy and extract a constant called check checkedSuperUserPrivilege ®, taking role as an argument. And create an extracted checkSuperUserPrivilege method that returns void. forexample
private static final String ERROR_FORMAT = "You must have the following privileges in order to assign them: %s";
private void checkSuperUserPrivilege(Role r) {
if(r.getRole().equals(RoleConstants.SUPERUSER)
&& !Context.hasPrivilege(PrivilegeConstants.ASSIGN_SYSTEM_DEVELOPER_ROLE)) {
> throw new APIException("User.you.must.have.role", new Object[] { RoleConstants.SUPERUSER });
> }
Extracting this code would make the original more concise with the same functionality, but i was so disturbed since it may need other guidance before creating a pull request. Yes this will be against the ticket description ticket but to make the code more concise and use lambda expression ,i was thinking this can take us miles,Doing this wont make the work being finished because there is no usage of lambda expressions,Meaning i will again use lambda if this format is accepted,thanks more suggestion is highly appreciated. cc @dkayiwa, @ibacher,@mozzy