Skip to content

Commit

Permalink
Ammend Fitzpatrick function documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
wax911 committed Jun 18, 2020
1 parent d944408 commit a6df5fd
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions emojify/src/main/java/io/wax911/emojify/util/Fitzpatrick.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.wax911.emojify.util

import java.util.*


/**
* Enum that represents the Fitzpatrick modifiers supported by the emojis.
*
Expand Down Expand Up @@ -36,19 +37,18 @@ enum class Fitzpatrick constructor(val unicode: String) {

companion object {

fun fitzpatrickFromUnicode(unicode: String?): Fitzpatrick? {
return values().find {
it.unicode == unicode
}
}

fun fitzpatrickFromType(type: String): Fitzpatrick? {
return runCatching {
/**
* @return [Fitzpatrick] or null if no [unicode] matches the supported types
*/
fun fitzpatrickFromUnicode(unicode: String?): Fitzpatrick? =
values().find { it.unicode == unicode }

/**
* @return [Fitzpatrick] or null if no [type] the available enum names
*/
fun fitzpatrickFromType(type: String): Fitzpatrick? =
runCatching {
valueOf(type.toUpperCase(Locale.ROOT))
}.getOrElse {
it.printStackTrace()
null
}
}
}.onFailure { it.printStackTrace() }.getOrNull()
}
}

0 comments on commit a6df5fd

Please sign in to comment.