Remove java.util.* imports from common code.

This commit is contained in:
Ilya Gorbunov
2016-11-16 21:06:57 +03:00
parent b4fbedbc9e
commit 50cd620f92
21 changed files with 9 additions and 40 deletions
-2
View File
@@ -16,8 +16,6 @@
package kotlin package kotlin
import java.util.*
/** /**
* Returns an empty array of the specified type [T]. * Returns an empty array of the specified type [T].
*/ */
-1
View File
@@ -17,7 +17,6 @@
package kotlin.dom package kotlin.dom
import org.w3c.dom.* import org.w3c.dom.*
import java.util.*
import kotlin.dom.* import kotlin.dom.*
import kotlin.collections.* import kotlin.collections.*
@@ -20,8 +20,6 @@
package kotlin.collections package kotlin.collections
import java.util.*
/** Returns the array if it's not `null`, or an empty array otherwise. */ /** Returns the array if it's not `null`, or an empty array otherwise. */
public inline fun <reified T> Array<out T>?.orEmpty(): Array<out T> = this ?: arrayOf<T>() public inline fun <reified T> Array<out T>?.orEmpty(): Array<out T> = this ?: arrayOf<T>()
@@ -19,7 +19,6 @@
package kotlin.collections package kotlin.collections
import java.util.*
import kotlin.comparisons.compareValues import kotlin.comparisons.compareValues
internal object EmptyIterator : ListIterator<Nothing> { internal object EmptyIterator : ListIterator<Nothing> {
@@ -89,7 +88,7 @@ public inline fun <T> listOf(): List<T> = emptyList()
* The returned list is serializable. * The returned list is serializable.
*/ */
@JvmVersion @JvmVersion
public fun <T> listOf(element: T): List<T> = Collections.singletonList(element) public fun <T> listOf(element: T): List<T> = java.util.Collections.singletonList(element)
/** Returns a new [MutableList] with the given elements. */ /** Returns a new [MutableList] with the given elements. */
public fun <T> mutableListOf(vararg elements: T): MutableList<T> public fun <T> mutableListOf(vararg elements: T): MutableList<T>
@@ -137,7 +136,7 @@ public inline fun <T> List<T>?.orEmpty(): List<T> = this ?: emptyList()
*/ */
@JvmVersion @JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun <T> Enumeration<T>.toList(): List<T> = Collections.list(this) public inline fun <T> java.util.Enumeration<T>.toList(): List<T> = java.util.Collections.list(this)
/** /**
* Checks if all elements in the specified collection are contained in this collection. * Checks if all elements in the specified collection are contained in this collection.
@@ -160,7 +159,7 @@ private fun <T> Array<out T>.copyToArrayOfAny(isVarargs: Boolean): Array<Any?> =
// if the array came from varargs and already is array of Any, copying isn't required // if the array came from varargs and already is array of Any, copying isn't required
@Suppress("UNCHECKED_CAST") (this as Array<Any?>) @Suppress("UNCHECKED_CAST") (this as Array<Any?>)
else else
Arrays.copyOf(this, this.size, Array<Any?>::class.java) java.util.Arrays.copyOf(this, this.size, Array<Any?>::class.java)
/** /**
* Searches this list or its range for the provided [element] using the binary search algorithm. * Searches this list or its range for the provided [element] using the binary search algorithm.
@@ -3,13 +3,11 @@
package kotlin.collections package kotlin.collections
import java.util.*
/** /**
* Creates an [Iterator] for an [Enumeration], allowing to use it in `for` loops. * Creates an [Iterator] for an [Enumeration], allowing to use it in `for` loops.
*/ */
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
public operator fun <T> Enumeration<T>.iterator(): Iterator<T> = object : Iterator<T> { public operator fun <T> java.util.Enumeration<T>.iterator(): Iterator<T> = object : Iterator<T> {
override fun hasNext(): Boolean = hasMoreElements() override fun hasNext(): Boolean = hasMoreElements()
public override fun next(): T = nextElement() public override fun next(): T = nextElement()
@@ -3,8 +3,6 @@
package kotlin.collections package kotlin.collections
import java.util.*
/** /**
* Returns the value for the given key, or the implicit default value for this map. * Returns the value for the given key, or the implicit default value for this map.
* By default no implicit value is provided for maps and a [NoSuchElementException] is thrown. * By default no implicit value is provided for maps and a [NoSuchElementException] is thrown.
@@ -3,8 +3,6 @@
package kotlin.collections package kotlin.collections
import java.util.*
private object EmptyMap : Map<Any?, Nothing>, Serializable { private object EmptyMap : Map<Any?, Nothing>, Serializable {
private const val serialVersionUID: Long = 8246714829545688274 private const val serialVersionUID: Long = 8246714829545688274
@@ -47,7 +45,7 @@ public inline fun <K, V> mapOf(): Map<K, V> = emptyMap()
* specified value. The returned map is serializable. * specified value. The returned map is serializable.
*/ */
@JvmVersion @JvmVersion
public fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V> = Collections.singletonMap(pair.first, pair.second) public fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V> = java.util.Collections.singletonMap(pair.first, pair.second)
/** /**
* Returns a new [MutableMap] with the specified contents, given as a list of pairs * Returns a new [MutableMap] with the specified contents, given as a list of pairs
@@ -568,4 +566,4 @@ internal inline fun <K, V> Map<K, V>.toSingletonMapOrSelf(): Map<K, V> = toSingl
// creates a singleton copy of map // creates a singleton copy of map
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
internal fun <K, V> Map<out K, V>.toSingletonMap(): Map<K, V> internal fun <K, V> Map<out K, V>.toSingletonMap(): Map<K, V>
= with (entries.iterator().next()) { Collections.singletonMap(key, value) } = with (entries.iterator().next()) { java.util.Collections.singletonMap(key, value) }
@@ -3,8 +3,6 @@
package kotlin.collections package kotlin.collections
import java.util.*
/** /**
* Removes a single instance of the specified element from this * Removes a single instance of the specified element from this
* collection, if it is present. * collection, if it is present.
@@ -3,8 +3,6 @@
package kotlin.sequences package kotlin.sequences
import java.util.*
/** /**
* Given an [iterator] function constructs a [Sequence] that returns values through the [Iterator] * Given an [iterator] function constructs a [Sequence] that returns values through the [Iterator]
* provided by that function. * provided by that function.
@@ -25,7 +23,7 @@ public fun <T> Iterator<T>.asSequence(): Sequence<T> = Sequence { this }.constra
*/ */
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun<T> Enumeration<T>.asSequence(): Sequence<T> = this.iterator().asSequence() public inline fun<T> java.util.Enumeration<T>.asSequence(): Sequence<T> = this.iterator().asSequence()
/** /**
* Creates a sequence that returns the specified values. * Creates a sequence that returns the specified values.
@@ -3,8 +3,6 @@
package kotlin.collections package kotlin.collections
import java.util.*
internal object EmptySet : Set<Nothing>, Serializable { internal object EmptySet : Set<Nothing>, Serializable {
private const val serialVersionUID: Long = 3406603774387020532 private const val serialVersionUID: Long = 3406603774387020532
@@ -61,7 +59,7 @@ public inline fun <T> Set<T>?.orEmpty(): Set<T> = this ?: emptySet()
* The returned set is serializable. * The returned set is serializable.
*/ */
@JvmVersion @JvmVersion
public fun <T> setOf(element: T): Set<T> = Collections.singleton(element) public fun <T> setOf(element: T): Set<T> = java.util.Collections.singleton(element)
/** /**
-1
View File
@@ -1,6 +1,5 @@
package test.comparisons package test.comparisons
import java.util.*
import kotlin.test.* import kotlin.test.*
import org.junit.Test import org.junit.Test
import kotlin.comparisons.* import kotlin.comparisons.*
@@ -18,7 +18,6 @@ package test.collections
import test.collections.behaviors.listBehavior import test.collections.behaviors.listBehavior
import test.comparisons.STRING_CASE_INSENSITIVE_ORDER import test.comparisons.STRING_CASE_INSENSITIVE_ORDER
import java.util.*
import kotlin.test.* import kotlin.test.*
import org.junit.Test as test import org.junit.Test as test
import kotlin.comparisons.* import kotlin.comparisons.*
@@ -16,7 +16,6 @@
package test.collections package test.collections
import java.util.*
import kotlin.test.* import kotlin.test.*
import org.junit.Test as test import org.junit.Test as test
import test.collections.behaviors.* import test.collections.behaviors.*
@@ -1,6 +1,5 @@
package test.collections package test.collections
import java.util.*
import kotlin.test.* import kotlin.test.*
import org.junit.Test as test import org.junit.Test as test
@@ -2,8 +2,6 @@ package test.collections
import kotlin.test.* import kotlin.test.*
import java.util.*
import org.junit.Test as test import org.junit.Test as test
class MutableCollectionTest { class MutableCollectionTest {
@@ -3,7 +3,6 @@ package test.collections
import org.junit.Test as test import org.junit.Test as test
import org.junit.Test import org.junit.Test
import kotlin.test.* import kotlin.test.*
import java.util.*
import kotlin.comparisons.* import kotlin.comparisons.*
fun fibonacci(): Sequence<Int> { fun fibonacci(): Sequence<Int> {
-1
View File
@@ -18,7 +18,6 @@ package test.collections.js
import org.junit.Test as test import org.junit.Test as test
import kotlin.test.* import kotlin.test.*
import java.util.*
class JsArrayTest { class JsArrayTest {
-1
View File
@@ -2,7 +2,6 @@ package test.collections.js
import kotlin.test.* import kotlin.test.*
import org.junit.Test as test import org.junit.Test as test
import java.util.*
import test.collections.* import test.collections.*
import test.collections.behaviors.* import test.collections.behaviors.*
-1
View File
@@ -4,7 +4,6 @@ import kotlin.test.*
import org.junit.Test import org.junit.Test
import test.collections.* import test.collections.*
import test.collections.behaviors.* import test.collections.behaviors.*
import java.util.*
class ComplexSetJsTest : SetJsTest() { class ComplexSetJsTest : SetJsTest() {
// Helper function with generic parameter to force to use ComlpexHashMap // Helper function with generic parameter to force to use ComlpexHashMap
+1 -2
View File
@@ -14,10 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
@file:JvmVersion
package test.collections.js package test.collections.js
import java.util.*
public fun <V> stringMapOf(vararg pairs: Pair<String, V>): HashMap<String, V> = hashMapOf<String, V>(*pairs) public fun <V> stringMapOf(vararg pairs: Pair<String, V>): HashMap<String, V> = hashMapOf<String, V>(*pairs)
public fun <V> linkedStringMapOf(vararg pairs: Pair<String, V>): LinkedHashMap<String, V> = linkedMapOf(*pairs) public fun <V> linkedStringMapOf(vararg pairs: Pair<String, V>): LinkedHashMap<String, V> = linkedMapOf(*pairs)
public fun stringSetOf(vararg elements: String): HashSet<String> = hashSetOf(*elements) public fun stringSetOf(vararg elements: String): HashSet<String> = hashSetOf(*elements)
@@ -1,7 +1,5 @@
package test.properties.delegation.map package test.properties.delegation.map
import java.util.*
import kotlin.properties.*
import kotlin.test.* import kotlin.test.*
import org.junit.Test as test import org.junit.Test as test