added not null helper methods for Set and Map

This commit is contained in:
James Strachan
2012-02-24 17:25:59 +00:00
parent 8faf1e62d3
commit 9523be50de
2 changed files with 11 additions and 2 deletions
+5
View File
@@ -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 <K, V> JMap<K, V>.set(key : K, value : V) = this.put(key, value)
/** Converts the nullable Map into an empty Map if its null */
inline fun <K,V> java.util.Map<K,V>?.notNull() : java.util.Map<K,V>
= if (this != null) this else Collections.EMPTY_MAP as java.util.Map<K,V>
/** Returns the key of the entry */
// Temporary workaround: commenting out