Package org.apache.guacamole.properties
Class EnumGuacamoleProperty<T extends Enum<T>>
- java.lang.Object
-
- org.apache.guacamole.properties.EnumGuacamoleProperty<T>
-
- Type Parameters:
T- The enum which defines the possible values of this property.
- All Implemented Interfaces:
GuacamoleProperty<T>
public abstract class EnumGuacamoleProperty<T extends Enum<T>> extends Object implements GuacamoleProperty<T>
A GuacamoleProperty whose possible values are defined by an enum. Possible values may be defined either through providing an explicit mapping or through annotating the enum constant definitions with theEnumGuacamoleProperty.PropertyValueannotation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceEnumGuacamoleProperty.PropertyValueDefines the string value which should be accepted and parsed into the annotated enum constant.
-
Constructor Summary
Constructors Constructor Description EnumGuacamoleProperty(Class<T> enumClass)Creates a new EnumGuacamoleProperty which parses String property values into corresponding enum constants as defined by theEnumGuacamoleProperty.PropertyValueannotations associated with those constants.EnumGuacamoleProperty(String key, T value, Object... additional)Creates a new EnumGuacamoleProperty which parses the given String property values into the given corresponding enum constants.EnumGuacamoleProperty(Map<String,T> valueMapping)Creates a new EnumGuacamoleProperty which parses String property values into corresponding enum constants as defined by the given Map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TparseValue(String value)Parses the given string value into the type associated with this GuacamoleProperty.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.guacamole.properties.GuacamoleProperty
getName
-
-
-
-
Constructor Detail
-
EnumGuacamoleProperty
public EnumGuacamoleProperty(Map<String,T> valueMapping)
Creates a new EnumGuacamoleProperty which parses String property values into corresponding enum constants as defined by the given Map.- Parameters:
valueMapping- A Map which maps all legal String values to their corresponding enum constants.
-
EnumGuacamoleProperty
public EnumGuacamoleProperty(Class<T> enumClass)
Creates a new EnumGuacamoleProperty which parses String property values into corresponding enum constants as defined by theEnumGuacamoleProperty.PropertyValueannotations associated with those constants.- Parameters:
enumClass- The enum whose annotated constants should be used as legal values of this property.
-
EnumGuacamoleProperty
public EnumGuacamoleProperty(String key, T value, Object... additional) throws IllegalArgumentException
Creates a new EnumGuacamoleProperty which parses the given String property values into the given corresponding enum constants.- Parameters:
key- The first String value to accept as a legal value of this property.value- The enum constant thatkeyshould be parsed into.additional- Any additional key/value pairs to be included beyond the first. This array must be even in length, where each even element is a String key and each odd element is the enum constant value to be associated with the key immediately preceding it.- Throws:
IllegalArgumentException- If any provided key is not a String, if any provided value is not an enum constant from the given enum type, or if the length ofadditionalis not even.
-
-
Method Detail
-
parseValue
public T parseValue(String value) throws org.apache.guacamole.GuacamoleException
Description copied from interface:GuacamolePropertyParses the given string value into the type associated with this GuacamoleProperty.- Specified by:
parseValuein interfaceGuacamoleProperty<T extends Enum<T>>- Parameters:
value- The string value to parse.- Returns:
- The parsed value.
- Throws:
org.apache.guacamole.GuacamoleException- If an error occurs while parsing the provided value.
-
-