-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(common-enums): initial module docs
- Loading branch information
1 parent
78e9cf8
commit 5e7f557
Showing
1 changed file
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Module common-enums | ||
|
||
Common enums utilities for androidx-ktx-extras' modules. | ||
|
||
## Usage | ||
|
||
<a href="https://central.sonatype.com/artifact/io.github.edricchan03.androidx.common/common-enums"><img src="https://flat.badgen.net/maven/v/maven-central/io.github.edricchan03.androidx.common/common-enums" alt="Common Enums on Maven Central"></a> | ||
|
||
Common Enums is available on [Maven Central](https://central.sonatype.com) as the Maven coordinate [`io.github.edricchan03.androidx.common:common-enums`](https://central.sonatype.com/artifact/io.github.edricchan03.androidx.common/common-enums): | ||
|
||
`settings.gradle.kts` | ||
|
||
```kotlin | ||
dependencyResolutionManagement { | ||
// ... | ||
repositories { | ||
mavenCentral() | ||
} | ||
} | ||
``` | ||
|
||
### Kotlin/Groovy | ||
|
||
`build.gradle.kts` | ||
|
||
```kotlin | ||
implementation("io.github.edricchan03.androidx.common:common-enums:0.0.1") | ||
``` | ||
|
||
### TOML | ||
|
||
`gradle/libs.versions.toml`: | ||
|
||
```toml | ||
[libraries] | ||
androidxtra-common-enums = "io.github.edricchan03.androidx.common:common-enums:0.0.1" | ||
``` | ||
|
||
`build.gradle.kts`: | ||
|
||
```kotlin | ||
implementation(libs.androidxtra.common.enums) | ||
``` | ||
|
||
### Snapshots | ||
|
||
Alternatively, you can grab the latest built snapshot from Maven Central's snapshots | ||
repository: | ||
|
||
`settings.gradle.kts` | ||
|
||
```kotlin | ||
dependencyResolutionManagement { | ||
// ... | ||
repositories { | ||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") { | ||
// Optionally, you can specify that only snapshots are to be used | ||
mavenContent { | ||
snapshotsOnly() | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
#### Kotlin | ||
|
||
`build.gradle.kts`: | ||
|
||
```kotlin | ||
implementation("io.github.edricchan03.androidx.common:common-enums:0.0.1-SNAPSHOT") | ||
``` | ||
|
||
#### TOML | ||
|
||
`gradle/libs.versions.toml`: | ||
|
||
```toml | ||
[libaries] | ||
androidxtra-common-enums = "io.github.edricchan03.androidx.common:common-enums:0.0.1-SNAPSHOT" | ||
``` | ||
|
||
`build.gradle.kts`: | ||
|
||
```kotlin | ||
implementation(libs.androidxtra.common.enums) | ||
``` | ||
|
||
# Package io.github.edricchan03.androidx.common.enums | ||
|
||
Common enum utilities such as [`EnumFromValue`][io.github.edricchan03.androidx.common.enums.EnumFromValue]: | ||
|
||
```kotlin | ||
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 | ||
} | ||
} | ||
``` |