Enum Class PermissionLevel
- All Implemented Interfaces:
Serializable,Comparable<PermissionLevel>,Constable
This enumeration lists possible values for the access levels. Each user is assigned one of the following levels, based on the permission rules set up for the structure.
The permissions are linear - next permission level includes everything that was allowed in the previous permission level, and a serial number defined for each level can be used in comparing levels.
Usually, when a permission level is passed as a parameter, it's supposed to be @Nullable. A
null value is treated as NONE.
- Author:
- Igor Sereda
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe user is allowed to view and edit the structure, create and edit generators and effectors, and also change its properties and permissions and delete it.The user is allowed to view and edit the structure, create and edit generators and effectors in it.The user is allowed to view and edit the structure.Deprecated.No permissions - the user is not allowed to view this structure or know that it exists.View permission - the user is allowed to view the structure, but they cannot change it. -
Method Summary
Modifier and TypeMethodDescriptionstatic PermissionLevelfromSerial(int serial) Used to look up permission level by serial number.intbooleanincludes(PermissionLevel requiredPermission) Used to check whether effective permission is enough to do something:if (permission.includes(PermissionLevel.EDIT))static PermissionLevelReturns the enum constant of this class with the specified name.static PermissionLevel[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NONE
No permissions - the user is not allowed to view this structure or know that it exists. -
VIEW
View permission - the user is allowed to view the structure, but they cannot change it. -
EDIT
The user is allowed to view and edit the structure. -
EDIT_GENERATORS
Deprecated.UseAUTOMATEinstead. -
AUTOMATE
The user is allowed to view and edit the structure, create and edit generators and effectors in it. -
ADMIN
The user is allowed to view and edit the structure, create and edit generators and effectors, and also change its properties and permissions and delete it.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getSerial
public int getSerial()- Returns:
- serial number of the permission level
-
includes
Used to check whether effective permission is enough to do something:
if (permission.includes(PermissionLevel.EDIT))Any permission includes
NONElevel, andnullpermission level is treated asNONE.- Parameters:
requiredPermission- required permission level- Returns:
- true if this permission level includes everything that is allowed by requiredPermission level
- See Also:
-
fromSerial
Used to look up permission level by serial number. This is used in serialization or transferring permissions.
If serial number does not match one of the levels, the highest level with the serial number less than specified will be used.
- Parameters:
serial- serial number- Returns:
- the corresponding permission level
-
AUTOMATEinstead.