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 {
|
fun resolveLink(packageName: String): String {
|
||||||
// TODO should be able to do something like
|
// TODO should be able to do something like
|
||||||
// for (e in packageUrls.filterNulls()) {
|
// for (e in packageUrls.filterNotNull()) {
|
||||||
val entrySet = packagePrefixToUrls.entrySet()
|
val entrySet = packagePrefixToUrls.entrySet()
|
||||||
if (entrySet != null) {
|
if (entrySet != null) {
|
||||||
for (e in entrySet) {
|
for (e in entrySet) {
|
||||||
|
|||||||
@@ -39,16 +39,6 @@
|
|||||||
</pluginRepository>
|
</pluginRepository>
|
||||||
</pluginRepositories>
|
</pluginRepositories>
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>${junit-version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>stdlib</module>
|
<module>stdlib</module>
|
||||||
<module>kunit</module>
|
<module>kunit</module>
|
||||||
|
|||||||
@@ -14,6 +14,12 @@
|
|||||||
<artifactId>stdlib</artifactId>
|
<artifactId>stdlib</artifactId>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>${junit-version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -27,6 +33,15 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.goldin.plugins</groupId>
|
<groupId>com.goldin.plugins</groupId>
|
||||||
<artifactId>kotlin-maven-plugin</artifactId>
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile-kotlin-sources</id>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
<goal>testCompile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</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 */
|
/** 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 */
|
/** 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) {
|
if (this != null) {
|
||||||
for (elem in this) {
|
for (elem in this) {
|
||||||
if (elem != null)
|
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 */
|
/** 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 */
|
/** 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) {
|
if (this != null) {
|
||||||
for (elem in this) {
|
for (elem in this) {
|
||||||
if (elem != null)
|
if (elem != null)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class StringUtilTest() : TestCase() {
|
|||||||
|
|
||||||
fun testToRegex() {
|
fun testToRegex() {
|
||||||
val re = """foo""".toRegex()
|
val re = """foo""".toRegex()
|
||||||
val list = re.split("hellofoobar").filterNulls()
|
val list = re.split("hellofoobar").filterNotNull()
|
||||||
assertEquals(arrayList("hello", "bar"), list)
|
assertEquals(arrayList("hello", "bar"), list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user