summaryrefslogtreecommitdiffstats
path: root/components/core
diff options
context:
space:
mode:
Diffstat (limited to 'components/core')
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt12
1 files changed, 12 insertions, 0 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
index f53f8615..40210142 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
@@ -122,6 +122,11 @@ object JacksonUtils {
}
@JvmStatic
+ fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {
+ return getListFromJson(node.toString(), valueType)
+ }
+
+ @JvmStatic
fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {
val objectMapper = jacksonObjectMapper()
val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)
@@ -149,6 +154,13 @@ object JacksonUtils {
}
@JvmStatic
+ fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {
+ val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())
+ ?: throw BluePrintException(format("Failed to read json file : {}", fileName))
+ return getMapFromJson(content, valueType)
+ }
+
+ @JvmStatic
fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {
if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
return checkJsonNodeValueOfPrimitiveType(type, jsonNode)