summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/MapAction.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/MapAction.java')
-rw-r--r--src/main/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/MapAction.java92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/main/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/MapAction.java b/src/main/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/MapAction.java
new file mode 100644
index 0000000..b7988f4
--- /dev/null
+++ b/src/main/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/MapAction.java
@@ -0,0 +1,92 @@
+package org.onap.sdc.dcae.composition.restmodels.ruleeditor;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import com.google.gson.annotations.SerializedName;
+
+public class MapAction extends BaseAction {
+
+ private Transform map;
+
+ public Transform getMap() {
+ return map;
+ }
+
+ public void setMap(Transform map) {
+ this.map = map;
+ }
+
+ public List<UIHashMap> getMapValues() {
+ return null == map? null : map.values;
+ }
+
+ public boolean mapHasDefault() {
+ return null != map && map.haveDefault;
+ }
+
+ public String getMapDefaultValue() {
+ return null == map? null : map.defaultValue;
+ }
+
+
+ private class Transform {
+ @SerializedName("default")
+ private String defaultValue;
+ private boolean haveDefault;
+ private List<UIHashMap> values;
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public boolean isHaveDefault() {
+ return haveDefault;
+ }
+
+ public void setHaveDefault(boolean haveDefault) {
+ this.haveDefault = haveDefault;
+ }
+
+ public List<UIHashMap> getValues() {
+ return values;
+ }
+
+ public void setValues(List<UIHashMap> values) {
+ this.values = values;
+ }
+
+ }
+
+ private class UIHashMap {
+ private String key;
+ private String value;
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ }
+
+ public Map<String, String> transformToMap() throws IllegalStateException {
+ return getMap().getValues().stream().collect(Collectors.toMap(UIHashMap::getKey, UIHashMap::getValue));
+ }
+
+}