You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/03/04 13:08:20 UTC

[GitHub] [cloudstack] JoaoJandre commented on a change in pull request #6048: Refactor account type

JoaoJandre commented on a change in pull request #6048:
URL: https://github.com/apache/cloudstack/pull/6048#discussion_r819555090



##########
File path: api/src/main/java/org/apache/cloudstack/acl/RoleType.java
##########
@@ -68,26 +80,15 @@ public static RoleType fromMask(int mask) {
         return Unknown;
     }
 
-    public static RoleType getByAccountType(final short accountType) {
-        RoleType roleType = RoleType.Unknown;
-        switch (accountType) {
-            case Account.ACCOUNT_TYPE_ADMIN:
-                roleType = RoleType.Admin;
-                break;
-            case Account.ACCOUNT_TYPE_DOMAIN_ADMIN:
-                roleType = RoleType.DomainAdmin;
-                break;
-            case Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN:
-                roleType = RoleType.ResourceAdmin;
-                break;
-            case Account.ACCOUNT_TYPE_NORMAL:
-                roleType = RoleType.User;
-                break;
+    public static RoleType getByAccountType(final Account.Type accountType) {
+        RoleType t = ACCOUNT_TYPE_MAP.get(accountType);
+        if (t == null) {

Review comment:
       I prefer not to use contracted ifs, I believe it worsens the legibility for no gain whatsoever.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org