refactored filterNulls() to filterNotNull() which is a clearer name - thanks Stepan!
This commit is contained in:
@@ -55,7 +55,7 @@ class KDocConfig() {
|
||||
*/
|
||||
fun resolveLink(packageName: String): String {
|
||||
// TODO should be able to do something like
|
||||
// for (e in packageUrls.filterNulls()) {
|
||||
// for (e in packageUrls.filterNotNull()) {
|
||||
val entrySet = packagePrefixToUrls.entrySet()
|
||||
if (entrySet != null) {
|
||||
for (e in entrySet) {
|
||||
|
||||
@@ -39,16 +39,6 @@
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<modules>
|
||||
<module>stdlib</module>
|
||||
<module>kunit</module>
|
||||
|
||||
@@ -14,6 +14,12 @@
|
||||
<artifactId>stdlib</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -27,6 +33,15 @@
|
||||
<plugin>
|
||||
<groupId>com.goldin.plugins</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile-kotlin-sources</id>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -54,10 +54,10 @@ inline fun <T, C: Collection<in T>> java.lang.Iterable<T>.filterTo(result: C, pr
|
||||
}
|
||||
|
||||
/** Returns a List containing all the non null elements in this collection */
|
||||
inline fun <T> java.lang.Iterable<T?>?.filterNulls() : Collection<T> = filterNullsTo(java.util.ArrayList<T>())
|
||||
inline fun <T> java.lang.Iterable<T?>?.filterNotNull() : Collection<T> = filterNotNullTo(java.util.ArrayList<T>())
|
||||
|
||||
/** Filters all the null elements in this collection winto the given result collection */
|
||||
inline fun <T, C: Collection<in T>> java.lang.Iterable<T?>?.filterNullsTo(result: C) : C {
|
||||
inline fun <T, C: Collection<in T>> java.lang.Iterable<T?>?.filterNotNullTo(result: C) : C {
|
||||
if (this != null) {
|
||||
for (elem in this) {
|
||||
if (elem != null)
|
||||
|
||||
@@ -57,10 +57,10 @@ inline fun <T, C: Collection<in T>> Array<T>.filterTo(result: C, predicate: (T)-
|
||||
}
|
||||
|
||||
/** Returns a List containing all the non null elements in this collection */
|
||||
inline fun <T> Array<T?>?.filterNulls() : Collection<T> = filterNullsTo(java.util.ArrayList<T>())
|
||||
inline fun <T> Array<T?>?.filterNotNull() : Collection<T> = filterNotNullTo(java.util.ArrayList<T>())
|
||||
|
||||
/** Filters all the null elements in this collection winto the given result collection */
|
||||
inline fun <T, C: Collection<in T>> Array<T?>?.filterNullsTo(result: C) : C {
|
||||
inline fun <T, C: Collection<in T>> Array<T?>?.filterNotNullTo(result: C) : C {
|
||||
if (this != null) {
|
||||
for (elem in this) {
|
||||
if (elem != null)
|
||||
|
||||
@@ -10,7 +10,7 @@ class StringUtilTest() : TestCase() {
|
||||
|
||||
fun testToRegex() {
|
||||
val re = """foo""".toRegex()
|
||||
val list = re.split("hellofoobar").filterNulls()
|
||||
val list = re.split("hellofoobar").filterNotNull()
|
||||
assertEquals(arrayList("hello", "bar"), list)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user