Package org.chenile.cucumber
Enum Class CukesContext
- All Implemented Interfaces:
Serializable
,Comparable<CukesContext>
,Constable
A singleton object that is used in all the methods to store and retrieve values
Cucumber recommends an enum since it acts like a perfect singleton. We could have also used a static instance as an alternative.
Cucumber recommends an enum since it acts like a perfect singleton. We could have also used a static instance as an alternative.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprivate
Pushes a hash map into the thread local so that we can now use the hash map to store and retrieve stuff -
Method Summary
Modifier and TypeMethodDescriptioncontext()
This uses a Thread Local to set and retrieve values<T> T
A convenience method that retrieves the thread local and retrieves values against keysvoid
reset()
Resets the map.void
A convenience method that retrieves the thread local and stores stuff into it.static CukesContext
Returns the enum constant of this class with the specified name.static CukesContext[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
CONTEXT
-
-
Field Details
-
c
-
-
Constructor Details
-
CukesContext
private CukesContext()Pushes a hash map into the thread local so that we can now use the hash map to store and retrieve stuff
-
-
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
-
context
This uses a Thread Local to set and retrieve values- Returns:
- a map of all the current values stored within the thread.
-
set
A convenience method that retrieves the thread local and stores stuff into it.- Parameters:
key
- the key to store againstvalue
- the value to store in the key
-
get
A convenience method that retrieves the thread local and retrieves values against keys- Type Parameters:
T
- this avoids the need to cast the results.- Parameters:
key
- the key to use- Returns:
- the value stored in the key
-
reset
public void reset()Resets the map. Happens at the end of every scenario.
-