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

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

There is a newer version: 1.2.8
Show newest version
package com.divpundir.mavlink.api

/**
 * Wrapper class for a [MavBitmask].
 */
public class MavBitmaskValue private constructor(public val flags: List, public val value: UInt) {

    public companion object {

        public fun  of(flags: List): MavBitmaskValue = MavBitmaskValue(
            flags,
            flags.map { it.value }
                .reduceOrNull { bitmask, value -> bitmask or value }
                ?: 0u
        )

        public fun  of(vararg flags: E): MavBitmaskValue = of(flags.asList())

        public fun  fromValue(value: UInt): MavBitmaskValue = MavBitmaskValue(emptyList(), value)
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (other == null || this::class != other::class) return false

        other as MavBitmaskValue<*>

        return value == other.value
    }

    override fun hashCode(): Int = value.hashCode()

    override fun toString(): String = "MavBitmaskValue(flags=$flags, value=$value)"
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy