Package io.openems.common.utils
Class EnumUtils
java.lang.Object
io.openems.common.utils.EnumUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAsBoolean
(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) static <ENUM extends Enum<ENUM>>
intGets the member of theEnumMap
as int.static <ENUM extends Enum<ENUM>>
com.google.gson.JsonArraygetAsJsonArray
(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) Gets the member of theEnumMap
asJsonArray
.getAsOptionalBoolean
(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) getAsOptionalEnum
(Class<E> enumType, EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) getAsOptionalInt
(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) getAsOptionalString
(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) static <ENUM extends Enum<ENUM>>
com.google.gson.JsonPrimitivegetAsPrimitive
(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) Gets the member of theEnumMap
asJsonPrimitive
.getAsString
(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) static <ENUM extends Enum<ENUM>>
com.google.gson.JsonElementgetSubElement
(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) Gets the member of theEnumMap
asJsonElement
.
-
Constructor Details
-
EnumUtils
public EnumUtils()
-
-
Method Details
-
getAsOptionalBoolean
public static <ENUM extends Enum<ENUM>> Optional<Boolean> getAsOptionalBoolean(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) - Type Parameters:
ENUM
- the type of the EnumMap key- Parameters:
map
- theEnumMap
member
- the member- Returns:
- the
Optional
Boolean
value - Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsOptionalEnum
-
getAsOptionalString
public static <ENUM extends Enum<ENUM>> Optional<String> getAsOptionalString(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) - Type Parameters:
ENUM
- the type of the EnumMap key- Parameters:
map
- theEnumMap
member
- the member- Returns:
- the
Optional
String
value - Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsOptionalInt
public static <ENUM extends Enum<ENUM>> Optional<Integer> getAsOptionalInt(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) - Type Parameters:
ENUM
- the type of the EnumMap key- Parameters:
map
- theEnumMap
member
- the member- Returns:
- the
Optional
Integer
value - Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsPrimitive
public static <ENUM extends Enum<ENUM>> com.google.gson.JsonPrimitive getAsPrimitive(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) throws OpenemsError.OpenemsNamedExceptionGets the member of theEnumMap
asJsonPrimitive
.- Type Parameters:
ENUM
- the type of the EnumMap key- Parameters:
map
- theEnumMap
member
- the member- Returns:
- the
JsonPrimitive
value - Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsJsonArray
public static <ENUM extends Enum<ENUM>> com.google.gson.JsonArray getAsJsonArray(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) throws OpenemsError.OpenemsNamedExceptionGets the member of theEnumMap
asJsonArray
.- Type Parameters:
ENUM
- the type of the EnumMap key- Parameters:
map
- theEnumMap
member
- the member- Returns:
- the
JsonArray
value - Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsBoolean
public static <ENUM extends Enum<ENUM>> Boolean getAsBoolean(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) throws OpenemsError.OpenemsNamedException- Type Parameters:
ENUM
- the type of the EnumMap key- Parameters:
map
- theEnumMap
member
- the member- Returns:
- the
Boolean
value - Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsEnum
public static <ENUM extends Enum<ENUM>,E extends Enum<E>> E getAsEnum(Class<E> enumType, EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) throws OpenemsError.OpenemsNamedException- Type Parameters:
ENUM
- the typeEnumMap
E
- theEnum
type- Parameters:
enumType
- the class of theEnum
map
- theEnumMap
member
- the member- Returns:
- the enum value
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsString
public static <ENUM extends Enum<ENUM>> String getAsString(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) throws OpenemsError.OpenemsNamedException- Type Parameters:
ENUM
- the type of the EnumMap key- Parameters:
map
- theEnumMap
member
- the member- Returns:
- the
String
value - Throws:
OpenemsError.OpenemsNamedException
- on error
-
getSubElement
public static <ENUM extends Enum<ENUM>> com.google.gson.JsonElement getSubElement(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) throws OpenemsError.OpenemsNamedExceptionGets the member of theEnumMap
asJsonElement
.- Type Parameters:
ENUM
- the type of the EnumMap key- Parameters:
map
- theEnumMap
member
- the member- Returns:
- the
JsonElement
value - Throws:
OpenemsError.OpenemsNamedException
- on error
-
getAsInt
public static <ENUM extends Enum<ENUM>> int getAsInt(EnumMap<ENUM, com.google.gson.JsonElement> map, ENUM member) throws OpenemsError.OpenemsNamedExceptionGets the member of theEnumMap
as int.- Type Parameters:
ENUM
- the type of the EnumMap key- Parameters:
map
- theEnumMap
member
- the member- Returns:
- the int value
- Throws:
OpenemsError.OpenemsNamedException
- on error
-