diff --git a/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/SharedKeys.kt b/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/VssDataKey.kt similarity index 58% rename from vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/SharedKeys.kt rename to vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/VssDataKey.kt index 1f4f2fe5..6dac9bad 100644 --- a/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/SharedKeys.kt +++ b/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/VssDataKey.kt @@ -20,25 +20,24 @@ package org.eclipse.kuksa.vssprocessor.parser const val ROOT_KEY_VEHICLE = "Vehicle" +const val KEY_CHILDREN = "children" -const val KEY_DATA_DESCRIPTION = "description" -const val KEY_DATA_TYPE = "type" -const val KEY_DATA_UUID = "uuid" -const val KEY_DATA_COMMENT = "comment" -const val KEY_DATA_DATATYPE = "datatype" -const val KEY_DATA_UNIT = "unit" -const val KEY_DATA_MIN = "min" -const val KEY_DATA_MAX = "max" -const val KEY_DATA_CHILDREN = "children" +enum class VssDataKey { + UUID, + TYPE, + DESCRIPTION, + COMMENT, + DATATYPE, + UNIT, + MIN, + MAX, + ; -val VSS_DATA_KEYS = listOf( - KEY_DATA_DESCRIPTION, - KEY_DATA_TYPE, - KEY_DATA_UUID, - KEY_DATA_COMMENT, - KEY_DATA_UNIT, - KEY_DATA_DATATYPE, - KEY_DATA_MIN, - KEY_DATA_MAX, - KEY_DATA_CHILDREN, -) + val key = name.lowercase() + + companion object { + fun findByKey(key: String): VssDataKey? { + return entries.find { it.key == key } + } + } +} diff --git a/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/json/JsonVssParser.kt b/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/json/JsonVssParser.kt index 12a987fc..ce7b30ae 100644 --- a/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/json/JsonVssParser.kt +++ b/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/json/JsonVssParser.kt @@ -22,18 +22,19 @@ package org.eclipse.kuksa.vssprocessor.parser.json import com.google.gson.Gson import com.google.gson.JsonObject import com.google.gson.JsonParseException -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_CHILDREN -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_COMMENT -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_DATATYPE -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_DESCRIPTION -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_MAX -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_MIN -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_TYPE -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_UNIT -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_UUID +import org.eclipse.kuksa.vssprocessor.parser.KEY_CHILDREN import org.eclipse.kuksa.vssprocessor.parser.ROOT_KEY_VEHICLE -import org.eclipse.kuksa.vssprocessor.parser.VSS_DATA_KEYS +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.COMMENT +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.DATATYPE +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.DESCRIPTION +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.MAX +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.MIN +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.TYPE +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.UNIT +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.UUID import org.eclipse.kuksa.vssprocessor.parser.VssParser +import org.eclipse.kuksa.vssprocessor.parser.json.extension.get import org.eclipse.kuksa.vssprocessor.spec.VssNodePropertiesBuilder import org.eclipse.kuksa.vssprocessor.spec.VssNodeSpecModel import java.io.File @@ -72,11 +73,12 @@ internal class JsonVssParser : VssParser { val parsedSpecModel = parseSpecModel(vssPath, jsonObject) parsedSpecModels += parsedSpecModel - if (jsonObject.has(KEY_DATA_CHILDREN)) { - val childrenJsonElement = jsonObject.getAsJsonObject(KEY_DATA_CHILDREN) + if (jsonObject.has(KEY_CHILDREN)) { + val childrenJsonElement = jsonObject.getAsJsonObject(KEY_CHILDREN) val filteredKeys = childrenJsonElement.asMap().keys - .filter { key -> !VSS_DATA_KEYS.contains(key) } + .filter { key -> key != KEY_CHILDREN } + .filter { key -> VssDataKey.findByKey(key) == null } filteredKeys.forEach { key -> val childJsonElement = childrenJsonElement.getAsJsonObject(key) @@ -93,18 +95,18 @@ internal class JsonVssParser : VssParser { vssPath: String, jsonObject: JsonObject, ): VssNodeSpecModel { - val uuid = jsonObject.get(KEY_DATA_UUID)?.asString - ?: throw JsonParseException("Could not parse '$KEY_DATA_UUID' for '$vssPath'") - - val type = jsonObject.get(KEY_DATA_TYPE)?.asString - ?: throw JsonParseException("Could not parse '$KEY_DATA_TYPE' for '$vssPath'") - - val description = jsonObject.get(KEY_DATA_DESCRIPTION)?.asString ?: "" - val datatype = jsonObject.get(KEY_DATA_DATATYPE)?.asString ?: "" - val comment = jsonObject.get(KEY_DATA_COMMENT)?.asString ?: "" - val unit = jsonObject.get(KEY_DATA_UNIT)?.asString ?: "" - val min = jsonObject.get(KEY_DATA_MIN)?.asString ?: "" - val max = jsonObject.get(KEY_DATA_MAX)?.asString ?: "" + val uuid = jsonObject.get(UUID)?.asString + ?: throw JsonParseException("Could not parse '${UUID.key}' for '$vssPath'") + + val type = jsonObject.get(TYPE)?.asString + ?: throw JsonParseException("Could not parse '${TYPE.key}' for '$vssPath'") + + val description = jsonObject.get(DESCRIPTION)?.asString ?: "" + val datatype = jsonObject.get(DATATYPE)?.asString ?: "" + val comment = jsonObject.get(COMMENT)?.asString ?: "" + val unit = jsonObject.get(UNIT)?.asString ?: "" + val min = jsonObject.get(MIN)?.asString ?: "" + val max = jsonObject.get(MAX)?.asString ?: "" val vssNodeProperties = VssNodePropertiesBuilder(uuid, type) .withDescription(description) diff --git a/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/json/extension/JsonObjectExtension.kt b/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/json/extension/JsonObjectExtension.kt new file mode 100644 index 00000000..84395eab --- /dev/null +++ b/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/json/extension/JsonObjectExtension.kt @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 - 2024 Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * + */ + +package org.eclipse.kuksa.vssprocessor.parser.json.extension + +import com.google.gson.JsonElement +import com.google.gson.JsonObject +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey + +internal fun JsonObject.has(vssDataKey: VssDataKey): Boolean { + return has(vssDataKey.key) +} + +internal fun JsonObject.getAsJsonObject(vssDataKey: VssDataKey): JsonObject { + return getAsJsonObject(vssDataKey.key) +} + +internal fun JsonObject.get(vssDataKey: VssDataKey): JsonElement? { + return get(vssDataKey.key) +} diff --git a/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/yaml/YamlVssParser.kt b/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/yaml/YamlVssParser.kt index 4eb4faf1..d59a55d1 100644 --- a/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/yaml/YamlVssParser.kt +++ b/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/parser/yaml/YamlVssParser.kt @@ -20,14 +20,15 @@ package org.eclipse.kuksa.vssprocessor.parser.yaml import org.eclipse.kuksa.vssprocessor.parser.FileParseException -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_COMMENT -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_DATATYPE -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_DESCRIPTION -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_MAX -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_MIN -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_TYPE -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_UNIT -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_UUID +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.COMMENT +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.DATATYPE +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.DESCRIPTION +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.MAX +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.MIN +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.TYPE +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.UNIT +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.UUID import org.eclipse.kuksa.vssprocessor.parser.VssParser import org.eclipse.kuksa.vssprocessor.spec.VssNodePropertiesBuilder import org.eclipse.kuksa.vssprocessor.spec.VssNodeSpecModel @@ -81,20 +82,20 @@ internal class YamlVssParser(private val elementDelimiter: String = "") : VssPar .substringAfter(delimiter) // Remove vssPath (already parsed) .prependIndent(delimiter.toString()) // So the parsing is consistent for the first element - val uuid = fetchValue(KEY_DATA_UUID, yamlElementJoined, delimiter).ifEmpty { - throw FileParseException("Could not parse '$KEY_DATA_UUID' for '$vssPath'") + val uuid = fetchValue(UUID, yamlElementJoined, delimiter).ifEmpty { + throw FileParseException("Could not parse '${UUID.key}' for '$vssPath'") } - val type = fetchValue(KEY_DATA_TYPE, yamlElementJoined, delimiter).ifEmpty { - throw FileParseException("Could not parse '$KEY_DATA_TYPE' for '$vssPath'") + val type = fetchValue(TYPE, yamlElementJoined, delimiter).ifEmpty { + throw FileParseException("Could not parse '${TYPE.key}' for '$vssPath'") } - val description = fetchValue(KEY_DATA_DESCRIPTION, yamlElementJoined, delimiter) - val datatype = fetchValue(KEY_DATA_DATATYPE, yamlElementJoined, delimiter) - val comment = fetchValue(KEY_DATA_COMMENT, yamlElementJoined, delimiter) - val unit = fetchValue(KEY_DATA_UNIT, yamlElementJoined, delimiter) - val min = fetchValue(KEY_DATA_MIN, yamlElementJoined, delimiter) - val max = fetchValue(KEY_DATA_MAX, yamlElementJoined, delimiter) + val description = fetchValue(DESCRIPTION, yamlElementJoined, delimiter) + val comment = fetchValue(COMMENT, yamlElementJoined, delimiter) + val datatype = fetchValue(DATATYPE, yamlElementJoined, delimiter) + val unit = fetchValue(UNIT, yamlElementJoined, delimiter) + val min = fetchValue(MIN, yamlElementJoined, delimiter) + val max = fetchValue(MAX, yamlElementJoined, delimiter) val vssNodeProperties = VssNodePropertiesBuilder(uuid, type) .withDescription(description) @@ -110,12 +111,12 @@ internal class YamlVssParser(private val elementDelimiter: String = "") : VssPar } private fun fetchValue( - nodeName: String, + dataKey: VssDataKey, yamlElementJoined: String, delimiter: Char, ): String { // Also parse the delimiter to not confuse type != datatype return yamlElementJoined - .substringAfter("$delimiter$nodeName: ") + .substringAfter("$delimiter${dataKey.key}: ") .substringBefore(delimiter) } diff --git a/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/spec/VssNodePropertiesBuilder.kt b/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/spec/VssNodePropertiesBuilder.kt index 5adc5738..1ce25948 100644 --- a/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/spec/VssNodePropertiesBuilder.kt +++ b/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/spec/VssNodePropertiesBuilder.kt @@ -19,35 +19,36 @@ package org.eclipse.kuksa.vssprocessor.spec -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_COMMENT -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_DATATYPE -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_DESCRIPTION -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_MAX -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_MIN -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_TYPE -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_UNIT -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_UUID +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.COMMENT +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.DATATYPE +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.DESCRIPTION +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.MAX +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.MIN +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.TYPE +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.UNIT +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.UUID import kotlin.reflect.KClass internal class VssNodePropertiesBuilder( uuid: String, type: String, ) { - private val nodePropertyMap: MutableMap = mutableMapOf() + private val nodePropertyMap: MutableMap = mutableMapOf() init { - val uuidNodeProperty = VssNodeProperty(KEY_DATA_UUID, uuid, String::class) - nodePropertyMap[KEY_DATA_UUID] = uuidNodeProperty + val uuidNodeProperty = VssNodeProperty(UUID, uuid, String::class) + nodePropertyMap[UUID] = uuidNodeProperty - val typeNodeProperty = VssNodeProperty(KEY_DATA_TYPE, type, String::class) - nodePropertyMap[KEY_DATA_TYPE] = typeNodeProperty + val typeNodeProperty = VssNodeProperty(TYPE, type, String::class) + nodePropertyMap[TYPE] = typeNodeProperty } fun withDescription(description: String): VssNodePropertiesBuilder { if (description.isEmpty()) return this - val nodeProperty = VssNodeProperty(KEY_DATA_DESCRIPTION, description, String::class) - nodePropertyMap[KEY_DATA_DESCRIPTION] = nodeProperty + val nodeProperty = VssNodeProperty(DESCRIPTION, description, String::class) + nodePropertyMap[DESCRIPTION] = nodeProperty return this } @@ -55,8 +56,8 @@ internal class VssNodePropertiesBuilder( fun withComment(comment: String): VssNodePropertiesBuilder { if (comment.isEmpty()) return this - val nodeProperty = VssNodeProperty(KEY_DATA_COMMENT, comment, String::class) - nodePropertyMap[KEY_DATA_COMMENT] = nodeProperty + val nodeProperty = VssNodeProperty(COMMENT, comment, String::class) + nodePropertyMap[COMMENT] = nodeProperty return this } @@ -66,8 +67,8 @@ internal class VssNodePropertiesBuilder( val valueDataType = findKClass(dataType) - val signalProperty = VssSignalProperty(KEY_DATA_DATATYPE, dataType, valueDataType) - nodePropertyMap[KEY_DATA_DATATYPE] = signalProperty + val signalProperty = VssSignalProperty(DATATYPE, dataType, valueDataType) + nodePropertyMap[DATATYPE] = signalProperty return this } @@ -75,8 +76,8 @@ internal class VssNodePropertiesBuilder( fun withUnit(unit: String): VssNodePropertiesBuilder { if (unit.isEmpty()) return this - val signalProperty = VssSignalProperty(KEY_DATA_UNIT, unit, String::class) - nodePropertyMap[KEY_DATA_UNIT] = signalProperty + val signalProperty = VssSignalProperty(UNIT, unit, String::class) + nodePropertyMap[UNIT] = signalProperty return this } @@ -84,8 +85,8 @@ internal class VssNodePropertiesBuilder( fun withMin(min: String, clazz: KClass<*>): VssNodePropertiesBuilder { if (min.isEmpty()) return this - val signalProperty = VssSignalProperty(KEY_DATA_MIN, min, clazz) - nodePropertyMap[KEY_DATA_MIN] = signalProperty + val signalProperty = VssSignalProperty(MIN, min, clazz) + nodePropertyMap[MIN] = signalProperty return this } @@ -101,8 +102,8 @@ internal class VssNodePropertiesBuilder( fun withMax(max: String, clazz: KClass<*>): VssNodePropertiesBuilder { if (max.isEmpty()) return this - val maxSignalProperty = VssSignalProperty(KEY_DATA_MAX, max, clazz) - nodePropertyMap[KEY_DATA_MAX] = maxSignalProperty + val maxSignalProperty = VssSignalProperty(MAX, max, clazz) + nodePropertyMap[MAX] = maxSignalProperty return this } diff --git a/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/spec/VssNodeProperty.kt b/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/spec/VssNodeProperty.kt index ffbc0f1b..0a8f2f42 100644 --- a/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/spec/VssNodeProperty.kt +++ b/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/spec/VssNodeProperty.kt @@ -19,33 +19,30 @@ package org.eclipse.kuksa.vssprocessor.spec +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey import kotlin.reflect.KClass internal open class VssNodeProperty( - val nodePropertyName: String, - val nodePropertyValue: String, + val dataKey: VssDataKey, + val value: String, val dataType: KClass<*>, ) { - open val isCommon: Boolean = true - override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false other as VssNodeProperty - return nodePropertyName == other.nodePropertyName + return dataKey == other.dataKey } override fun hashCode(): Int { - return nodePropertyName.hashCode() + return dataKey.hashCode() } } internal class VssSignalProperty( - nodePropertyName: String, - nodePropertyValue: String, + dataKey: VssDataKey, + value: String, dataType: KClass<*>, -) : VssNodeProperty(nodePropertyName, nodePropertyValue, dataType) { - override val isCommon: Boolean = false -} +) : VssNodeProperty(dataKey, value, dataType) diff --git a/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/spec/VssNodeSpecModel.kt b/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/spec/VssNodeSpecModel.kt index 0ba8ec4e..944d3e12 100644 --- a/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/spec/VssNodeSpecModel.kt +++ b/vss-processor/src/main/kotlin/org/eclipse/kuksa/vssprocessor/spec/VssNodeSpecModel.kt @@ -42,11 +42,7 @@ import org.eclipse.kuksa.vsscore.model.name import org.eclipse.kuksa.vsscore.model.parentClassName import org.eclipse.kuksa.vsscore.model.parentKey import org.eclipse.kuksa.vsscore.model.variableName -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_COMMENT -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_DATATYPE -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_DESCRIPTION -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_TYPE -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_UUID +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.* import org.eclipse.kuksa.vssprocessor.spec.VssNodeProperty.* import kotlin.reflect.KClass import kotlin.reflect.KProperty1 @@ -57,13 +53,13 @@ internal class VssNodeSpecModel( val vssNodeProperties: Set, ) : VssNode, SpecModel { - private val propertyNameToNodePropertyMap = vssNodeProperties.associateBy { it.nodePropertyName } + private val propertyNameToNodePropertyMap = vssNodeProperties.associateBy { it.dataKey } - override var uuid: String = propertyNameToNodePropertyMap[KEY_DATA_UUID]?.nodePropertyValue ?: "" - override var type: String = propertyNameToNodePropertyMap[KEY_DATA_TYPE]?.nodePropertyValue ?: "" - override var description: String = propertyNameToNodePropertyMap[KEY_DATA_DESCRIPTION]?.nodePropertyValue ?: "" - override var comment: String = propertyNameToNodePropertyMap[KEY_DATA_COMMENT]?.nodePropertyValue ?: "" - var datatype: String = propertyNameToNodePropertyMap[KEY_DATA_DATATYPE]?.nodePropertyValue ?: "" + override val uuid: String = propertyNameToNodePropertyMap[UUID]?.value ?: "" + override val type: String = propertyNameToNodePropertyMap[TYPE]?.value ?: "" + override val description: String = propertyNameToNodePropertyMap[DESCRIPTION]?.value ?: "" + override val comment: String = propertyNameToNodePropertyMap[COMMENT]?.value ?: "" + val datatype: String = propertyNameToNodePropertyMap[DATATYPE]?.value ?: "" var logger: KSPLogger? = null @@ -206,15 +202,16 @@ internal class VssNodeSpecModel( ) propertySpecs.add(genericClassSpec) val vssSignalProperties = vssNodeProperties + .filterIsInstance() .filter { - !it.isCommon && it.nodePropertyName != VssSignal<*>::dataType.name.lowercase() + it.dataKey.key != VssSignal<*>::dataType.name.lowercase() } vssSignalProperties.forEach { vssSignalProperty -> - val value = vssSignalProperty.nodePropertyValue + val value = vssSignalProperty.value if (value.isEmpty()) return@forEach - val propertyName = vssSignalProperty.nodePropertyName.lowercase() + val propertyName = vssSignalProperty.dataKey.key val propertyType = vssSignalProperty.dataType val returnStatement = getReturnStatement(vssSignalProperty.dataType) val propertySpec = PropertySpec diff --git a/vss-processor/src/test/kotlin/org/eclipse/kuksa/vssprocessor/parser/json/JsonVssParserTest.kt b/vss-processor/src/test/kotlin/org/eclipse/kuksa/vssprocessor/parser/json/JsonVssParserTest.kt index dc125880..79ffebe3 100644 --- a/vss-processor/src/test/kotlin/org/eclipse/kuksa/vssprocessor/parser/json/JsonVssParserTest.kt +++ b/vss-processor/src/test/kotlin/org/eclipse/kuksa/vssprocessor/parser/json/JsonVssParserTest.kt @@ -25,9 +25,9 @@ import io.kotest.matchers.shouldBe import io.kotest.matchers.string.shouldContain import io.kotest.matchers.types.instanceOf import org.eclipse.kuksa.test.TestResourceFile -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_MAX -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_MIN -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_UNIT +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.MAX +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.MIN +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.UNIT import java.io.IOException class JsonVssParserTest : BehaviorSpec({ @@ -109,16 +109,16 @@ class JsonVssParserTest : BehaviorSpec({ specModel.datatype shouldBe "float" specModel.vssNodeProperties .find { - it.nodePropertyName == KEY_DATA_MIN - }?.nodePropertyValue shouldBe "0" + it.dataKey == MIN + }?.value shouldBe "0" specModel.vssNodeProperties .find { - it.nodePropertyName == KEY_DATA_MAX - }?.nodePropertyValue shouldBe "100" + it.dataKey == MAX + }?.value shouldBe "100" specModel.vssNodeProperties .find { - it.nodePropertyName == KEY_DATA_UNIT - }?.nodePropertyValue shouldBe "percent" + it.dataKey == UNIT + }?.value shouldBe "percent" } } diff --git a/vss-processor/src/test/kotlin/org/eclipse/kuksa/vssprocessor/parser/yaml/YamlVssParserTest.kt b/vss-processor/src/test/kotlin/org/eclipse/kuksa/vssprocessor/parser/yaml/YamlVssParserTest.kt index 63095144..fb3f6412 100644 --- a/vss-processor/src/test/kotlin/org/eclipse/kuksa/vssprocessor/parser/yaml/YamlVssParserTest.kt +++ b/vss-processor/src/test/kotlin/org/eclipse/kuksa/vssprocessor/parser/yaml/YamlVssParserTest.kt @@ -25,9 +25,9 @@ import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe import io.kotest.matchers.string.shouldContain import org.eclipse.kuksa.test.TestResourceFile -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_MAX -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_MIN -import org.eclipse.kuksa.vssprocessor.parser.KEY_DATA_UNIT +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.MAX +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.MIN +import org.eclipse.kuksa.vssprocessor.parser.VssDataKey.UNIT class YamlVssParserTest : BehaviorSpec({ given("A parser for yaml files") { @@ -107,16 +107,16 @@ class YamlVssParserTest : BehaviorSpec({ specModel.datatype shouldBe "float" specModel.vssNodeProperties .find { - it.nodePropertyName == KEY_DATA_MIN - }?.nodePropertyValue shouldBe "0" + it.dataKey == MIN + }?.value shouldBe "0" specModel.vssNodeProperties .find { - it.nodePropertyName == KEY_DATA_MAX - }?.nodePropertyValue shouldBe "100" + it.dataKey == MAX + }?.value shouldBe "100" specModel.vssNodeProperties .find { - it.nodePropertyName == KEY_DATA_UNIT - }?.nodePropertyValue shouldBe "percent" + it.dataKey == UNIT + }?.value shouldBe "percent" } }