Minor: Refactor AptMode a bit

This commit is contained in:
Yan Zhulanow
2018-10-19 23:04:28 +03:00
parent fe0f9005b0
commit fa0f447a23
@@ -399,8 +399,11 @@ class Kapt3ComponentRegistrar : ComponentRegistrar {
} }
} }
enum class AptMode { enum class AptMode(val optionName: String) {
WITH_COMPILATION, STUBS_AND_APT, STUBS_ONLY, APT_ONLY; WITH_COMPILATION("compile"),
STUBS_AND_APT("stubsAndApt"),
STUBS_ONLY("stubs"),
APT_ONLY("apt");
val runAnnotationProcessing val runAnnotationProcessing
get() = this != STUBS_ONLY get() = this != STUBS_ONLY
@@ -410,12 +413,12 @@ enum class AptMode {
companion object { companion object {
// Supports both deprecated APT_ONLY and new APT_MODE options // Supports both deprecated APT_ONLY and new APT_MODE options
fun parse(mode: String?): AptMode = when (mode) { fun parse(mode: String?): AptMode {
"true", "stubsAndApt" -> STUBS_AND_APT return when (mode) {
"false", "compile" -> WITH_COMPILATION "true" -> STUBS_AND_APT
"apt" -> APT_ONLY "false" -> WITH_COMPILATION
"stubs" -> STUBS_ONLY else -> AptMode.values().firstOrNull { it.optionName == mode } ?: WITH_COMPILATION
else -> WITH_COMPILATION }
} }
} }
} }