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
+6 -2
View File
@@ -55,8 +55,12 @@ inline fun <in T: java.lang.Comparable<T>> List<T>.sort(comparator: java.util.Co
}
/** Converts the nullable List into an empty List if its null */
inline fun <T> java.util.List<T>?.notNull() : List<T>
= if (this != null) this else Collections.EMPTY_LIST as List<T>
inline fun <T> java.util.List<T>?.notNull() : java.util.List<T>
= if (this != null) this else Collections.EMPTY_LIST as java.util.List<T>
/** Converts the nullable Set into an empty Set if its null */
inline fun <T> java.util.Set<T>?.notNull() : java.util.Set<T>
= if (this != null) this else Collections.EMPTY_SET as java.util.Set<T>
/**
TODO figure out necessary variance/generics ninja stuff... :)