[skip-ci] refactor: removed overloaded valueOf

merge-requests/1/merge
see 2 years ago
parent 27f090557a
commit 15dfba6b6e

@ -43,6 +43,8 @@ fun Prov.provisionDesktop(
gitEmail: String? = null,
) = task {
DesktopType.valueOf(desktopType.name) // throws exception when desktopType.name is unknown
if (!currentUserCanSudo()) {
throw Exception("Current user ${whoami()} cannot execute sudo without entering a password! This is necessary to execute provisionDesktop")
}

@ -17,13 +17,10 @@ open class DesktopType(val name: String) {
@JvmStatic
protected val values = listOf(BASIC, OFFICE, IDE)
fun valueOf(value: String): DesktopType {
return valueOf(value, values)
}
fun valueOf(value: String, v: List<DesktopType>): DesktopType {
for (t in v) {
if (value.uppercase().equals(t.name)) {
return t
fun valueOf(value: String, valueList: List<DesktopType> = values): DesktopType {
for (type in valueList) {
if (value.uppercase().equals(type.name)) {
return type
}
}
throw RuntimeException("No DesktopType found for value: $value")

Loading…
Cancel
Save