Package org.jbehave.core.steps
Class ParameterConverters.FluentEnumConverter
- java.lang.Object
-
- org.jbehave.core.steps.ParameterConverters.AbstractParameterConverter<String,T>
-
- org.jbehave.core.steps.ParameterConverters.FromStringParameterConverter<Enum<?>>
-
- org.jbehave.core.steps.ParameterConverters.EnumConverter
-
- org.jbehave.core.steps.ParameterConverters.FluentEnumConverter
-
- All Implemented Interfaces:
ParameterConverters.ParameterConverter<String,Enum<?>>
- Enclosing class:
- ParameterConverters
public static class ParameterConverters.FluentEnumConverter extends ParameterConverters.EnumConverter
An
ParameterConverters.EnumConverter
allowing stories prose to be more natural. Before performing the actual conversion, it ransforms values to upper-case, with any non-alphanumeric character replaced by an underscore ('_').Example: assuming we have defined the step "
Given I am on the $page
" which is mapped to the methodiAmOnPage(PageEnum page)
, we can then write in a scenario:
instead of:Given I am on the login page
Given I am on the LOGIN_PAGE
Warning. This requires enum constants to follow the standard conventions for constant names, i.e. all uppercase letters, with words separated by underscores.
-
-
Constructor Summary
Constructors Constructor Description FluentEnumConverter()
-
Method Summary
Modifier and Type Method Description Enum<?>
convertValue(String value, Type type)
Convert the value from one type to another, for example from aboolean
to aString
.-
Methods inherited from class org.jbehave.core.steps.ParameterConverters.EnumConverter
canConvertTo
-
Methods inherited from class org.jbehave.core.steps.ParameterConverters.AbstractParameterConverter
canConvertFrom, getSourceType, getTargetType
-
-
-
-
Method Detail
-
convertValue
public Enum<?> convertValue(String value, Type type)
Description copied from interface:ParameterConverters.ParameterConverter
Convert the value from one type to another, for example from aboolean
to aString
.- Specified by:
convertValue
in interfaceParameterConverters.ParameterConverter<String,Enum<?>>
- Overrides:
convertValue
in classParameterConverters.EnumConverter
- Parameters:
value
- the value to be convertedtype
- the type descriptor that supplies extra information about the requested result type- Returns:
- the converted value
-
-