@@ -51,6 +51,35 @@ enum ListOperation {
5151 }
5252}
5353
54+ /// Defines the operation to be perfomed on a map type variable.
55+ enum MapOperation {
56+ /// Replace entire map.
57+ replace,
58+
59+ /// Add [newValue] to the map.
60+ add,
61+
62+ /// Remove [key] from the map.
63+ remove,
64+
65+ /// Update value at [key] with [newValue] in the map.
66+ update;
67+
68+ /// Returns a string representation of this enum.
69+ String get prettify {
70+ switch (this ) {
71+ case MapOperation .replace:
72+ return 'Replace' ;
73+ case MapOperation .add:
74+ return 'Add' ;
75+ case MapOperation .remove:
76+ return 'Remove' ;
77+ case MapOperation .update:
78+ return 'Update' ;
79+ }
80+ }
81+ }
82+
5483/// An action that sets value of a variable.
5584@JsonSerializable ()
5685class SetVariableAction extends ActionModel
@@ -73,13 +102,23 @@ class SetVariableAction extends ActionModel
73102 /// Used for list type variable.
74103 final String index;
75104
105+ /// Operation to be performed on the map type variable.
106+ final MapOperation mapOperation;
107+
108+ /// Key of the map to be updated/removed.
109+ /// Can be a discrete value or a variable refered by '${}' syntax.
110+ /// Used for map type variable.
111+ final String key;
112+
76113 /// Creates a new [SetValueAction] .
77114 SetVariableAction ({
78115 required this .variable,
79116 required this .newValue,
80117 this .toggled = false ,
81118 this .listOperation = ListOperation .replace,
82119 this .index = '0' ,
120+ this .mapOperation = MapOperation .replace,
121+ this .key = 'key' ,
83122 }) : super (type: ActionType .setVariable);
84123
85124 @override
@@ -92,13 +131,17 @@ class SetVariableAction extends ActionModel
92131 bool ? toggled,
93132 ListOperation ? listOperation,
94133 String ? index,
134+ MapOperation ? mapOperation,
135+ String ? key,
95136 }) =>
96137 SetVariableAction (
97138 variable: variable ?? this .variable,
98139 newValue: newValue ?? this .newValue,
99140 toggled: toggled ?? this .toggled,
100141 listOperation: listOperation ?? this .listOperation,
101142 index: index ?? this .index,
143+ mapOperation: mapOperation ?? this .mapOperation,
144+ key: key ?? this .key,
102145 );
103146
104147 /// Creates a new [SetVariableAction] instance from a JSON data.
0 commit comments