commonMain.com.divpundir.mavlink.api.AbstractMavDialect.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api-jvm Show documentation
Show all versions of api-jvm Show documentation
A modern MAVLink library for the JVM written in Kotlin.
package com.divpundir.mavlink.api
import kotlinx.collections.immutable.toPersistentHashMap
import kotlinx.collections.immutable.toPersistentSet
public abstract class AbstractMavDialect(
dependencies: Set,
messages: Map>>
) : MavDialect {
override val dependencies: Set = dependencies.toPersistentSet()
override val messages: Map>> = messages.toPersistentHashMap()
override fun resolveCompanionOrNull(messageId: UInt): MavMessage.MavCompanion>? {
if (messages.containsKey(messageId)) {
return messages[messageId]
} else {
for (dependency in dependencies) {
val result = dependency.resolveCompanionOrNull(messageId)
if (result != null) {
return result
}
}
}
return null
}
override fun supports(messageId: UInt): Boolean {
if (messages.containsKey(messageId)) {
return true
} else {
for (dependency in dependencies) {
if (dependency.supports(messageId)) {
return true
}
}
}
return false
}
}