All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.divpundir.mavlink.api.AbstractMavDialect.kt Maven / Gradle / Ivy

There is a newer version: 1.2.8
Show newest version
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
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy