Package io.openems.common.session
Enum Class Role
- All Implemented Interfaces:
Serializable
,Comparable<Role>
,Constable
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptioncom.google.gson.JsonPrimitive
asJson()
Gets the Role as a JsonPrimitive.assertIsAtLeast
(String resource, Role role) Throws an exception if the current Role is equal or more privileged than the given Role.int
getLevel()
The Level of this Role.static Role
Returns the Role ENUM for this name or "GUEST" if it was not found.boolean
Gets the information whether the current Role is equal or more privileged than the given Role.boolean
isLessThan
(Role role) Gets the information whether the current Role is less privileged than the given Role.static Role
Returns the enum constant of this class with the specified name.static Role[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ADMIN
-
INSTALLER
-
OWNER
-
GUEST
-
-
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
-
getLevel
public int getLevel()The Level of this Role. The lower the better.- Returns:
- the level
-
getRole
Returns the Role ENUM for this name or "GUEST" if it was not found.- Parameters:
name
- the name of the Role- Returns:
- the Role
-
isAtLeast
Gets the information whether the current Role is equal or more privileged than the given Role.- Parameters:
role
- the compared Role- Returns:
- true if the current Role privileges are equal or higher
-
assertIsAtLeast
Throws an exception if the current Role is equal or more privileged than the given Role.- Parameters:
resource
- a resource identifier; used for the exceptionrole
- the compared Role- Returns:
- the current Role
- Throws:
OpenemsError.OpenemsNamedException
- if the current Role privileges are less
-
isLessThan
Gets the information whether the current Role is less privileged than the given Role.- Parameters:
role
- the compared Role- Returns:
- true if the current Role is less privileged
-
asJson
public com.google.gson.JsonPrimitive asJson()Gets the Role as a JsonPrimitive.- Returns:
- the JsonPrimitive
-