Enum Class PermissionLevel

Object
Enum<PermissionLevel>
PermissionLevel
All Implemented Interfaces:
Serializable, Comparable<PermissionLevel>, Constable

public enum PermissionLevel extends Enum<PermissionLevel>

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 Constants
    Enum Constant
    Description
    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.
    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.
    Use AUTOMATE instead.
    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 Type
    Method
    Description
    fromSerial(int serial)
    Used to look up permission level by serial number.
    int
     
    boolean
    includes(PermissionLevel requiredPermission)
    Used to check whether effective permission is enough to do something: if (permission.includes(PermissionLevel.EDIT))
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • NONE

      public static final PermissionLevel NONE
      No permissions - the user is not allowed to view this structure or know that it exists.
    • VIEW

      public static final PermissionLevel VIEW
      View permission - the user is allowed to view the structure, but they cannot change it.
    • EDIT

      public static final PermissionLevel EDIT
      The user is allowed to view and edit the structure.
    • EDIT_GENERATORS

      @Deprecated public static final PermissionLevel EDIT_GENERATORS
      Deprecated.
      Use AUTOMATE instead.
    • AUTOMATE

      public static final PermissionLevel AUTOMATE
      The user is allowed to view and edit the structure, create and edit generators and effectors in it.
    • ADMIN

      public static final PermissionLevel 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

      public static PermissionLevel[] 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

      public static PermissionLevel valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • getSerial

      public int getSerial()
      Returns:
      serial number of the permission level
    • includes

      public boolean includes(@Nullable PermissionLevel requiredPermission)

      Used to check whether effective permission is enough to do something: if (permission.includes(PermissionLevel.EDIT))

      Any permission includes NONE level, and null permission level is treated as NONE.

      Parameters:
      requiredPermission - required permission level
      Returns:
      true if this permission level includes everything that is allowed by requiredPermission level
      See Also:
    • fromSerial

      @NotNull public static PermissionLevel fromSerial(int serial)

      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