Skip to content

Commit

Permalink
checkedNsOrNull
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Jul 21, 2024
1 parent ec06962 commit 11aa43e
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@ abstract class MappingResolver<T : MappingResolver<T>>(val name: String) {

}

fun checkedNs(name: String): Namespace {
fun checkedNsOrNull(name: String): Namespace? {
val ns = Namespace(name)
if (namespaces.keys.contains(ns)) {
return ns
}
throw IllegalArgumentException("Unknown namespace $name")
return null
}

fun checkedNs(name: String): Namespace {
return checkedNsOrNull(name) ?: throw IllegalArgumentException("Unknown namespace $name")
}

fun isOfficial(name: String): Boolean {
Expand Down

0 comments on commit 11aa43e

Please sign in to comment.