Formatting Code base with ktlint
[ccsdk/cds.git] / ms / controllerblueprints / modules / blueprint-core / src / main / kotlin / org / onap / ccsdk / cds / controllerblueprints / core / service / BluePrintExpressionService.kt
index fbf9116..6a3c646 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.core.service
 
-import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import com.fasterxml.jackson.databind.node.ArrayNode
 import com.fasterxml.jackson.databind.node.ObjectNode
@@ -25,7 +24,14 @@ import com.fasterxml.jackson.databind.node.TextNode
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DSLExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ExpressionData
+import org.onap.ccsdk.cds.controllerblueprints.core.data.InputExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationOutputExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyExpression
+import org.slf4j.LoggerFactory
 
 /**
  *
@@ -33,16 +39,16 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.*
  * @author Brinda Santh
  */
 object BluePrintExpressionService {
-    val log= LoggerFactory.getLogger(this::class.toString())
+
+    val log = LoggerFactory.getLogger(this::class.toString())
 
     @JvmStatic
     fun checkContainsExpression(propertyAssignmentNode: JsonNode): Boolean {
         val json = propertyAssignmentNode.toString()
         // FIXME("Check if any Optimisation needed")
-        return (json.contains(BluePrintConstants.EXPRESSION_GET_INPUT)
-                || json.contains(BluePrintConstants.EXPRESSION_GET_ATTRIBUTE)
-                || json.contains(BluePrintConstants.EXPRESSION_GET_PROPERTY))
-
+        return (json.contains(BluePrintConstants.EXPRESSION_GET_INPUT) ||
+                json.contains(BluePrintConstants.EXPRESSION_GET_ATTRIBUTE) ||
+                json.contains(BluePrintConstants.EXPRESSION_GET_PROPERTY))
     }
 
     @JvmStatic
@@ -74,8 +80,9 @@ object BluePrintExpressionService {
                     }
                 }
             }
-        } else if (propertyAssignmentNode is TextNode
-                && propertyAssignmentNode.textValue().startsWith(BluePrintConstants.EXPRESSION_DSL_REFERENCE)) {
+        } else if (propertyAssignmentNode is TextNode &&
+            propertyAssignmentNode.textValue().startsWith(BluePrintConstants.EXPRESSION_DSL_REFERENCE)
+        ) {
             expressionData.isExpression = true
             expressionData.command = BluePrintConstants.EXPRESSION_DSL_REFERENCE
             expressionData.dslExpression = populateDSLExpression(propertyAssignmentNode)
@@ -85,8 +92,10 @@ object BluePrintExpressionService {
 
     @JvmStatic
     fun populateDSLExpression(jsonNode: TextNode): DSLExpression {
-        return DSLExpression(propertyName = jsonNode.textValue()
-                .removePrefix(BluePrintConstants.EXPRESSION_DSL_REFERENCE))
+        return DSLExpression(
+            propertyName = jsonNode.textValue()
+                .removePrefix(BluePrintConstants.EXPRESSION_DSL_REFERENCE)
+        )
     }
 
     @JvmStatic
@@ -98,9 +107,13 @@ object BluePrintExpressionService {
     fun populatePropertyExpression(jsonNode: JsonNode): PropertyExpression {
         val arrayNode: ArrayNode = jsonNode.first() as ArrayNode
         check(arrayNode.size() >= 2) {
-            throw BluePrintException(String.format("missing property expression, " +
-                    "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <property_name>, " +
-                    "<nested_property_name_or_index_1>, ..., <nested_property_name_or_index_n> ] , but present {}", jsonNode))
+            throw BluePrintException(
+                String.format(
+                    "missing property expression, " +
+                            "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <property_name>, " +
+                            "<nested_property_name_or_index_1>, ..., <nested_property_name_or_index_n> ] , but present {}", jsonNode
+                )
+            )
         }
         var reqOrCapEntityName: String? = null
         var propertyName = ""
@@ -121,10 +134,11 @@ object BluePrintExpressionService {
             }
         }
 
-        return PropertyExpression(modelableEntityName = arrayNode[0].asText(),
-                reqOrCapEntityName = reqOrCapEntityName,
-                propertyName = propertyName,
-                subPropertyName = subProperty
+        return PropertyExpression(
+            modelableEntityName = arrayNode[0].asText(),
+            reqOrCapEntityName = reqOrCapEntityName,
+            propertyName = propertyName,
+            subPropertyName = subProperty
         )
     }
 
@@ -132,9 +146,13 @@ object BluePrintExpressionService {
     fun populateAttributeExpression(jsonNode: JsonNode): AttributeExpression {
         val arrayNode: ArrayNode = jsonNode.first() as ArrayNode
         check(arrayNode.size() >= 2) {
-            throw BluePrintException(String.format("missing attribute expression, " +
-                    "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <attribute_name>," +
-                    " <nested_attribute_name_or_index_1>, ..., <nested_attribute_name_or_index_n> ] , but present {}", jsonNode))
+            throw BluePrintException(
+                String.format(
+                    "missing attribute expression, " +
+                            "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <attribute_name>," +
+                            " <nested_attribute_name_or_index_1>, ..., <nested_attribute_name_or_index_n> ] , but present {}", jsonNode
+                )
+            )
         }
 
         var reqOrCapEntityName: String? = null
@@ -155,10 +173,11 @@ object BluePrintExpressionService {
                 subAttributeName = propertyPaths.joinToString("/")
             }
         }
-        return AttributeExpression(modelableEntityName = arrayNode[0].asText(),
-                reqOrCapEntityName = reqOrCapEntityName,
-                attributeName = attributeName,
-                subAttributeName = subAttributeName
+        return AttributeExpression(
+            modelableEntityName = arrayNode[0].asText(),
+            reqOrCapEntityName = reqOrCapEntityName,
+            attributeName = attributeName,
+            subAttributeName = subAttributeName
         )
     }
 
@@ -167,19 +186,25 @@ object BluePrintExpressionService {
         val arrayNode: ArrayNode = jsonNode.first() as ArrayNode
 
         check(arrayNode.size() >= 4) {
-            throw BluePrintException(String.format("missing operation output expression, " +
-                    "it should be (<modelable_entity_name>, <interface_name>, <operation_name>, <output_variable_name>) , but present {}", jsonNode))
+            throw BluePrintException(
+                String.format(
+                    "missing operation output expression, " +
+                            "it should be (<modelable_entity_name>, <interface_name>, <operation_name>, <output_variable_name>) , but present {}",
+                    jsonNode
+                )
+            )
         }
 
         var subPropertyName: String? = null
         if (arrayNode.size() == 5)
             subPropertyName = arrayNode[4].asText()
 
-        return OperationOutputExpression(modelableEntityName = arrayNode[0].asText(),
-                interfaceName = arrayNode[1].asText(),
-                operationName = arrayNode[2].asText(),
-                propertyName = arrayNode[3].asText(),
-                subPropertyName = subPropertyName
+        return OperationOutputExpression(
+            modelableEntityName = arrayNode[0].asText(),
+            interfaceName = arrayNode[1].asText(),
+            operationName = arrayNode[2].asText(),
+            propertyName = arrayNode[3].asText(),
+            subPropertyName = subPropertyName
         )
     }
 
@@ -188,13 +213,18 @@ object BluePrintExpressionService {
         val arrayNode: ArrayNode = jsonNode.first() as ArrayNode
 
         check(arrayNode.size() >= 2) {
-            throw BluePrintException(String.format("missing artifact expression, " +
-                    "it should be [ <modelable_entity_name>, <artifact_name>, <location>, <remove> ] , but present {}", jsonNode))
+            throw BluePrintException(
+                String.format(
+                    "missing artifact expression, " +
+                            "it should be [ <modelable_entity_name>, <artifact_name>, <location>, <remove> ] , but present {}", jsonNode
+                )
+            )
         }
-        return ArtifactExpression(modelableEntityName = arrayNode[0].asText(),
-                artifactName = arrayNode[1].asText(),
-                location = arrayNode[2]?.asText() ?: "LOCAL_FILE",
-                remove = arrayNode[3]?.asBoolean() ?: false
+        return ArtifactExpression(
+            modelableEntityName = arrayNode[0].asText(),
+            artifactName = arrayNode[1].asText(),
+            location = arrayNode[2]?.asText() ?: "LOCAL_FILE",
+            remove = arrayNode[3]?.asBoolean() ?: false
         )
     }
-}
\ No newline at end of file
+}