From 2d879240396861aa253dd65b2476f35a2ffc0493 Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Thu, 1 Aug 2019 21:00:05 -0400 Subject: Add property definition type DSL. Change-Id: I83a3d1391c60cd426236b55d0d399e273e7c15dc Issue-ID: CCSDK-1577 Signed-off-by: Brinda Santh --- .../core/dsl/AbstractNodeTemplateImplBuilder.kt | 26 ---------------- .../AbstractNodeTemplateOperationImplBuilder.kt | 36 ++++++++++++++++++++++ .../core/dsl/BluePrintTemplateDSLBuilder.kt | 7 +++++ 3 files changed, 43 insertions(+), 26 deletions(-) delete mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateImplBuilder.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateOperationImplBuilder.kt (limited to 'ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org') diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateImplBuilder.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateImplBuilder.kt deleted file mode 100644 index 7ab139070..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateImplBuilder.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright © 2019 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.controllerblueprints.core.dsl - -abstract class AbstractNodeTemplateImplBuilder( - id: String, type: String, private val interfaceName: String, description: String -) : NodeTemplateBuilder(id, type, description) { - - open fun operation(description: String, block: OperationAssignmentBuilder.() -> Unit) { - typedOperation(interfaceName, description, block) - } -} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateOperationImplBuilder.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateOperationImplBuilder.kt new file mode 100644 index 000000000..182d9a050 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateOperationImplBuilder.kt @@ -0,0 +1,36 @@ +/* + * Copyright © 2019 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.controllerblueprints.core.dsl + +abstract class AbstractNodeTemplateOperationImplBuilder( + id: String, type: String, private val interfaceName: String, description: String +) : AbstractNodeTemplatePropertyImplBuilder(id, type, description) { + + open fun definedOperation(description: String, block: OperationAssignmentBuilder.() -> Unit) { + typedOperation(interfaceName, description, block) + } +} + +abstract class AbstractNodeTemplatePropertyImplBuilder( + id: String, type: String, description: String +) : NodeTemplateBuilder(id, type, description) { + + open fun definedProperties(block: Prop.() -> Unit) { + typedProperties(block) + } +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt index 685473f08..7f49a99c6 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt @@ -108,6 +108,13 @@ open class NodeTemplateBuilder(private val id: String, properties = PropertiesAssignmentBuilder().apply(block).build() } + open fun typedProperties(block: Prop.() -> Unit) { + if (properties == null) + properties = hashMapOf() + val instance: Prop = (block.reflect()?.parameters?.get(0)?.type?.classifier as KClass).createInstance() + properties = instance.apply(block).build() + } + open fun typedOperation( interfaceName: String, description: String = "", block: OperationAssignmentBuilder.() -> Unit) { -- cgit 1.2.3-korg