ravening commented on a change in pull request #6048:
URL: https://github.com/apache/cloudstack/pull/6048#discussion_r819374769
##########
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:
if you use `Type.UNKNOWN` rather than null then this can be simplified to
`return (t == UNKNOWN) ? RoleType.UNKNOWN : t`
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]