Skip to content

Commit

Permalink
chore: Remove unused Method
Browse files Browse the repository at this point in the history
  • Loading branch information
wba2hi committed Mar 21, 2024
1 parent 49e1b8f commit dd6fe35
Showing 1 changed file with 0 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.eclipse.kuksa.vssprocessor.parser.yaml

import org.eclipse.kuksa.vsscore.model.VssNode
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
Expand All @@ -36,9 +35,6 @@ import org.eclipse.kuksa.vssprocessor.spec.VssNodeSpecModel
import org.eclipse.kuksa.vssprocessor.spec.VssSignalProperty
import java.io.File
import java.io.IOException
import kotlin.reflect.KMutableProperty
import kotlin.reflect.KProperty
import kotlin.reflect.full.memberProperties

internal class YamlVssParser(private val elementDelimiter: String = "") : VssParser {
override fun parseNodes(vssFile: File): List<VssNodeSpecModel> {
Expand Down Expand Up @@ -121,31 +117,6 @@ internal class YamlVssParser(private val elementDelimiter: String = "") : VssPar
}
}

/**
* @param fields to set via reflection. Pair<PropertyName, anyValue>.
* @param remapNames which can be used if the propertyName does not match with the input name
*/
private fun VssNode.setFields(
fields: List<Pair<String, Any?>>,
remapNames: Map<String, String> = emptyMap(),
) {
val nameToProperty = this::class.memberProperties.associateBy(KProperty<*>::name)

val remappedFields = fields.toMutableList()
remapNames.forEach { (propertyName, newName) ->
val find = fields.find { it.first == propertyName } ?: return@forEach
remappedFields.remove(find)
remappedFields.add(Pair(find.first, newName))
}

remappedFields.forEach { (propertyName, propertyValue) ->
nameToProperty[propertyName]
.takeIf { it is KMutableProperty<*> }
?.let { it as KMutableProperty<*> }
?.setter?.call(this, propertyValue)
}
}

private fun fetchValue(
nodeName: String,
yamlElementJoined: String,
Expand Down

0 comments on commit dd6fe35

Please sign in to comment.