ApiVersion now enum

This commit is contained in:
Andrew Golovashevich 2025-05-16 16:27:17 +03:00
parent fe289fe8c5
commit 3d0d2ec38e
3 changed files with 11 additions and 19 deletions

View File

@ -1,24 +1,11 @@
package ru.landgrafhomyak.db.skeleton1.api
import kotlin.jvm.JvmField
public abstract class ApiVersion private constructor(public val str: String) {
override fun equals(other: Any?): Boolean {
if (other == null) return false
if (other !is ApiVersion) return false
return this === other
}
public enum class ApiVersion(public val str: String) {
V_0_0("0.0") {
override fun isImplements(v: ApiVersion) = this === v
};
override fun toString(): String = "<db-skeleton api version '${this.str}'>"
override fun hashCode(): Int = this.str.hashCode()
public abstract fun isImplements(lower: ApiVersion): Boolean
public companion object {
@JvmField
public val V_0_0: ApiVersion = object : ApiVersion("0.0") {
override fun isImplements(lower: ApiVersion) = this === lower
}
}
public abstract fun isImplements(v: ApiVersion): Boolean
}

View File

@ -14,5 +14,6 @@ public interface DriverMetainfo<
@Suppress("unused") STATEMENT_CONSTRUCTOR__PARAMS_2_TABLE : RawStatement.Params2Table.Constructor<*>,
@Suppress("unused") OBJECT_OPERATIONS : ObjectOperations<*>
> {
public val apiVersion: ApiVersion
@ReflectionApi
public fun isImplements(version: ApiVersion): Boolean
}

View File

@ -0,0 +1,4 @@
package ru.landgrafhomyak.db.skeleton1.api
@Retention(AnnotationRetention.BINARY)
public annotation class SinceApi(val version: ApiVersion)