Skip to content

Common Enums 0.0.1

Choose a tag to compare

@EdricChan03 EdricChan03 released this 30 Jun 16:53
· 160 commits to main since this release
common-enums@0.0.1
f79dead

Notable changes

  • This version is the initial release! 🎉

  • An abstract EnumFromValue class was added that all enums' companion object with an internal representation should inherit. An example usage is as shown below:

    enum class Example(val value: String) {
        One("one"),
        Two("two"),
        Three("abc");
    
        companion object : EnumFromValue<String, Example>(default = Three) {
            override fun fromValueOrNull(value: String) = when (value) {
                "one" -> One
                "two" -> Two
                "abc", "other value" -> Three
                else -> null
            }
        }
    }

Full Changelog: https://github.com/EdricChan03/androidx-ktx-extras/commits/common-enums@0.0.1

Usage

common-enums is published on Maven Central (as io.github.edricchan03.androidx.common:common-enums) and can be included in your dependencies as shown below:

Kotlin/Groovy

build.gradle.kts:

implementation("io.github.edricchan03.androidx.common:common-enums:0.0.1")

Version Catalogs

libs.versions.toml:

[libraries]
androidxtra-common-enums = "io.github.edricchan03.androidx.common:common-enums:0.0.1"

build.gradle.kts:

implementation(libs.androidxtra.common.enums)