public class PermissionUtils extends Object
Modifier and Type | Method and Description |
---|---|
static List<String> |
expandAllPermission(String permission)
Transforms a given permission into the expanded version with all of the permission types.
|
static Optional<String> |
getPermissionRoot(String permission)
Obtains the 'root' of the permission which is defined as anything that comes after one of the
PermissionType.prefixes() . |
static String |
getPermissionType(String permission)
Obtains the permission type of the given permission based on
PermissionType.prefixes() . |
public static List<String> expandAllPermission(@NonNull String permission)
permission
- a permission that starts with ALL_public static Optional<String> getPermissionRoot(@NonNull String permission)
PermissionType.prefixes()
. Example: given ALL_PRODUCT this will return PRODUCT and
given SOME_PERMISSION this will return an empty optionalpermission
- a permissionPermissionType.prefixes()
PermissionType.prefixes()
,
getPermissionType(String)
@Nullable public static String getPermissionType(@NonNull String permission)
PermissionType.prefixes()
. This assumes that the type is coded as a prefix in the
given permission. If no permission type can be found, this returns the entire given
permission unchanged.permission
- a permission to get the prefix forPermissionType.prefixes()
or the
permission unchanged if it does not have a prefixPermissionType.prefixes()
,
getPermissionRoot(String)
Copyright © 2021. All rights reserved.