summaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorVijay Venkatesh Kumar <vv770d@att.com>2020-10-01 14:18:20 +0000
committerGerrit Code Review <gerrit@onap.org>2020-10-01 14:18:20 +0000
commite669b34a5ca86cd6c41dd7e0430893c9b03f85bb (patch)
tree9a422eb75e4771dbcec79b486fca513037d33148 /mod
parent43a65d7605b852140a12f1398a152dea33112d87 (diff)
parentde5cdfc6343653056e35c0c528959dda1cc52c4b (diff)
Merge "Refactor ResourceConfig class"
Diffstat (limited to 'mod')
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java116
1 files changed, 62 insertions, 54 deletions
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java
index f750178..030374f 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java
@@ -21,7 +21,7 @@
package org.onap.blueprintgenerator.models.blueprint;
-import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createInputValue;
+import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createStringInput;
import java.util.LinkedHashMap;
import java.util.TreeMap;
@@ -34,86 +34,94 @@ import lombok.Setter;
//TODO: Auto-generated Javadoc
/* (non-Javadoc)
-* @see java.lang.Object#toString()
-*/
-@Getter @Setter
+ * @see java.lang.Object#toString()
+ */
+@Getter
+@Setter
/* (non-Javadoc)
-* @see java.lang.Object#toString()
-*/
+ * @see java.lang.Object#toString()
+ */
@Builder
/**
-* Instantiates a new resource config obj.
-*/
+ * Instantiates a new resource config obj.
+ */
@NoArgsConstructor
/**
-* Instantiates a new resource config obj.
-*
-* @param limits the limits
-* @param requests the requests
-*/
+ * Instantiates a new resource config obj.
+ *
+ * @param limits the limits
+ * @param requests the requests
+ */
@AllArgsConstructor
public class ResourceConfig {
- /** The limits. */
- private TreeMap<String, GetInput> limits;
+ /**
+ * The limits.
+ */
+ private TreeMap<String, GetInput> limits;
+
+ /**
+ * The requests.
+ */
+ private TreeMap<String, GetInput> requests;
- /** The requests. */
- private TreeMap<String, GetInput> requests;
+ /**
+ * Creates the resource config.
+ *
+ * @param inps the inps
+ * @param name the name
+ * @return the tree map
+ */
+ public TreeMap<String, LinkedHashMap<String, Object>> createResourceConfig(
+ TreeMap<String, LinkedHashMap<String, Object>> inps, String name) {
- /**
- * Creates the resource config.
- *
- * @param inps the inps
- * @param name the name
- * @return the tree map
- */
- public TreeMap<String, LinkedHashMap<String, Object>> createResourceConfig(TreeMap<String, LinkedHashMap<String, Object>> inps, String name){
+ LinkedHashMap<String, Object> memoryLimit = createStringInput("128Mi");
+ LinkedHashMap<String, Object> cpuLimit = createStringInput("250m");
- LinkedHashMap<String, Object> memoryLimit = createInputValue("string", "", "128Mi");
- LinkedHashMap<String, Object> cpuLimit = createInputValue("string", "", "250m");
+ String namePrefix = getNamePrefix(name);
- if(!name.equals("")) {
- name = name + "_";
- }
+ //set the limits
+ TreeMap<String, GetInput> limits = new TreeMap<>();
- //set the limits
- TreeMap<String, GetInput> limits = new TreeMap<>();
+ GetInput cpu = new GetInput();
+ cpu.setBpInputName(namePrefix + "cpu_limit");
+ limits.put("cpu", cpu);
- GetInput cpu = new GetInput();
- cpu.setBpInputName(name + "cpu_limit");
- limits.put("cpu", cpu);
+ GetInput memL = new GetInput();
+ memL.setBpInputName(namePrefix + "memory_limit");
+ limits.put("memory", memL);
- GetInput memL = new GetInput();
- memL.setBpInputName(name + "memory_limit");
- limits.put("memory", memL);
+ inps.put(namePrefix + "cpu_limit", cpuLimit);
+ inps.put(namePrefix + "memory_limit", memoryLimit);
- inps.put(name + "cpu_limit", cpuLimit);
- inps.put(name + "memory_limit", memoryLimit);
+ this.setLimits(limits);
- this.setLimits(limits);
+ //set the requests
+ TreeMap<String, GetInput> requests = new TreeMap<>();
- //set the requests
- TreeMap<String, GetInput> requests = new TreeMap<>();
+ GetInput cpuR = new GetInput();
+ cpuR.setBpInputName(namePrefix + "cpu_request");
+ requests.put("cpu", cpuR);
- GetInput cpuR = new GetInput();
- cpuR.setBpInputName(name + "cpu_request");
- requests.put("cpu", cpuR);
+ GetInput memR = new GetInput();
+ memR.setBpInputName(namePrefix + "memory_request");
+ requests.put("memory", memR);
- GetInput memR = new GetInput();
- memR.setBpInputName(name + "memory_request");
- requests.put("memory", memR);
+ inps.put(namePrefix + "cpu_request", cpuLimit);
+ inps.put(namePrefix + "memory_request", memoryLimit);
- inps.put(name + "cpu_request", cpuLimit);
- inps.put(name + "memory_request", memoryLimit);
+ this.setRequests(requests);
- this.setRequests(requests);
+ return inps;
+ }
- return inps;
- }
+ private String getNamePrefix(String name) {
+ return name.isEmpty() ? "" : name + "_";
+ }
}