summaryrefslogtreecommitdiffstats
path: root/common-be/src/main/java/org/openecomp
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2020-03-04 16:28:05 +0000
committerJulien Bertozzi <julien.bertozzi@intl.att.com>2020-07-29 11:39:50 +0000
commit5e8464585f07210ad4b20ddfee2c23b1cf2d8b2a (patch)
treed0e9b828f0b374f504115443814537deb35d49c1 /common-be/src/main/java/org/openecomp
parent18a43d537bc91d752377159fb0d5b3e9f5bdd6e5 (diff)
Config. allowed instances in component composition
During the creation of Resource and Services components, the allowed types to add in its composition are hard-coded. This change allows those types to be configurable using the configuration.yaml backend file. Change-Id: If48849b57fe5124468db3d55f2f06391348935fb Issue-ID: SDC-3177 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'common-be/src/main/java/org/openecomp')
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ResourceTypeEnum.java86
1 files changed, 44 insertions, 42 deletions
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ResourceTypeEnum.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ResourceTypeEnum.java
index bd32ace9e5..4201b79d6a 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ResourceTypeEnum.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ResourceTypeEnum.java
@@ -15,6 +15,8 @@
package org.openecomp.sdc.be.datatypes.enums;
+import java.util.Arrays;
+
/**
* Resource Type Enum
*
@@ -32,12 +34,13 @@ public enum ResourceTypeEnum {
VFCMT("VFCMT"/* (VFC Monitoring Template)"*/, true),
Configuration("Configuration", true),
ServiceProxy("ServiceProxy", true),
- ABSTRACT("Abstract (Generic VFC/VF/PNF/Service Type)", true);
+ //Generic VFC/VF/PNF/Service Type
+ ABSTRACT("Abstract", true);
- private String value;
- private boolean isAtomicType;
+ private final String value;
+ private final boolean isAtomicType;
- ResourceTypeEnum(String value, boolean isAtomicType) {
+ ResourceTypeEnum(final String value, final boolean isAtomicType) {
this.value = value;
this.isAtomicType = isAtomicType;
}
@@ -50,69 +53,68 @@ public enum ResourceTypeEnum {
return isAtomicType;
}
- public static ResourceTypeEnum getType(String type) {
- for (ResourceTypeEnum e : ResourceTypeEnum.values()) {
- if (e.name().equals(type)) {
- return e;
- }
+ public static ResourceTypeEnum getType(final String type) {
+ if (type == null) {
+ return null;
}
- return null;
+ return Arrays.stream(ResourceTypeEnum.values())
+ .filter(resourceTypeEnum -> resourceTypeEnum.name().equals(type))
+ .findFirst()
+ .orElse(null);
}
- public static ResourceTypeEnum getTypeByName(String type) {
- for (ResourceTypeEnum e : ResourceTypeEnum.values()) {
- if (e.name().equalsIgnoreCase(type)) {
- return e;
- }
+ public static ResourceTypeEnum getTypeByName(final String type) {
+ if (type == null) {
+ return null;
}
- return null;
+ return Arrays.stream(ResourceTypeEnum.values())
+ .filter(resourceTypeEnum -> resourceTypeEnum.name().equalsIgnoreCase(type))
+ .findFirst()
+ .orElse(null);
}
/**
* Returns ResourceTypeEnum matching to received String ignore case
*
- * @param type
- * @return
+ * @param type the resource type
+ * @return the resource type as a enum if found, {@code null} otherwise
*/
- public static ResourceTypeEnum getTypeIgnoreCase(String type) {
- for (ResourceTypeEnum e : ResourceTypeEnum.values()) {
- if (e.name().toLowerCase().equals(type.toLowerCase())) {
- return e;
- }
+ public static ResourceTypeEnum getTypeIgnoreCase(final String type) {
+ if (type == null) {
+ return null;
}
- return null;
+ return Arrays.stream(ResourceTypeEnum.values())
+ .filter(resourceTypeEnum -> resourceTypeEnum.name().equalsIgnoreCase(type))
+ .findFirst()
+ .orElse(null);
}
/**
* Checks if enum exist with given type
*
- * @param type
- * @return
+ * @param type the resource type
+ * @return {@code true} if the given resource type exists, {@code false} otherwise
*/
- public static boolean containsName(String type) {
-
- for (ResourceTypeEnum e : ResourceTypeEnum.values()) {
- if (e.name().equals(type)) {
- return true;
- }
+ public static boolean containsName(final String type) {
+ if (type == null) {
+ return false;
}
- return false;
+ return Arrays.stream(ResourceTypeEnum.values())
+ .anyMatch(resourceTypeEnum -> resourceTypeEnum.name().equals(type));
}
/**
* Checks if enum exist with given type ignore case
*
- * @param type
- * @return
+ * @param type the resource type
+ * @return {@code true} if the type exists, {@code false} otherwise
*/
- public static boolean containsIgnoreCase(String type) {
-
- for (ResourceTypeEnum e : ResourceTypeEnum.values()) {
- if (e.name().toLowerCase().equals(type.toLowerCase())) {
- return true;
- }
+ public static boolean containsIgnoreCase(final String type) {
+ if (type == null) {
+ return false;
}
- return false;
+ return Arrays.stream(ResourceTypeEnum.values())
+ .anyMatch(resourceTypeEnum -> resourceTypeEnum.name().equalsIgnoreCase(type));
}
}