commonMain.com.divpundir.mavlink.api.MavBitmaskValue.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
/**
* 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)"
}