diff --git a/stdlib/ktSrc/JavaUtil.kt b/stdlib/ktSrc/JavaUtil.kt index 6d0c7ce2de8..4c54219cb2a 100644 --- a/stdlib/ktSrc/JavaUtil.kt +++ b/stdlib/ktSrc/JavaUtil.kt @@ -55,8 +55,12 @@ inline fun > List.sort(comparator: java.util.Co } /** Converts the nullable List into an empty List if its null */ -inline fun java.util.List?.notNull() : List - = if (this != null) this else Collections.EMPTY_LIST as List +inline fun java.util.List?.notNull() : java.util.List + = if (this != null) this else Collections.EMPTY_LIST as java.util.List + +/** Converts the nullable Set into an empty Set if its null */ +inline fun java.util.Set?.notNull() : java.util.Set + = if (this != null) this else Collections.EMPTY_SET as java.util.Set /** TODO figure out necessary variance/generics ninja stuff... :) diff --git a/stdlib/ktSrc/JavaUtilMap.kt b/stdlib/ktSrc/JavaUtilMap.kt index 7c02d1f65cc..985e89225b5 100644 --- a/stdlib/ktSrc/JavaUtilMap.kt +++ b/stdlib/ktSrc/JavaUtilMap.kt @@ -2,6 +2,7 @@ package std.util import java.util.Map as JMap import java.util.HashMap +import java.util.Collections // Temporary workaround: commenting out //import java.util.Map.Entry as JEntry @@ -19,6 +20,10 @@ val JMap<*,*>.empty : Boolean /** Provides [] access to maps */ fun JMap.set(key : K, value : V) = this.put(key, value) +/** Converts the nullable Map into an empty Map if its null */ +inline fun java.util.Map?.notNull() : java.util.Map + = if (this != null) this else Collections.EMPTY_MAP as java.util.Map + /** Returns the key of the entry */ // Temporary workaround: commenting out