Some 200 warnings eliminated from stdlib code
This commit is contained in:
@@ -132,9 +132,7 @@ public inline fun <T, C: MutableCollection<in T>> Array<T?>?.filterNotNullTo(res
|
||||
public inline fun <T, R> Array<T>.flatMapTo(result: MutableCollection<R>, transform: (T) -> Collection<R>) : Collection<R> {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
if (list != null) {
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -172,7 +170,7 @@ public inline fun <T,R> Array<T>.foldRight(initial: R, operation: (T, R) -> R):
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun <T> Array<T>.reduce(operation: (T, T) -> T): T {
|
||||
val iterator = this.iterator()!!
|
||||
val iterator = this.iterator()
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +224,7 @@ public inline fun <T, K> Array<T>.groupByTo(result: MutableMap<K, MutableList<T>
|
||||
public inline fun <T> Array<T>.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()!!
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -132,9 +132,7 @@ public inline fun <C: MutableCollection<Boolean>> BooleanArray?.filterNotNullTo(
|
||||
public inline fun <R> BooleanArray.flatMapTo(result: MutableCollection<R>, transform: (Boolean) -> Collection<R>) : Collection<R> {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
if (list != null) {
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -172,7 +170,7 @@ public inline fun <R> BooleanArray.foldRight(initial: R, operation: (Boolean, R)
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun BooleanArray.reduce(operation: (Boolean, Boolean) -> Boolean): Boolean {
|
||||
val iterator = this.iterator()!!
|
||||
val iterator = this.iterator()
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +224,7 @@ public inline fun <K> BooleanArray.groupByTo(result: MutableMap<K, MutableList<B
|
||||
public inline fun BooleanArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()!!
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -132,9 +132,7 @@ public inline fun <C: MutableCollection<Byte>> ByteArray?.filterNotNullTo(result
|
||||
public inline fun <R> ByteArray.flatMapTo(result: MutableCollection<R>, transform: (Byte) -> Collection<R>) : Collection<R> {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
if (list != null) {
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -172,7 +170,7 @@ public inline fun <R> ByteArray.foldRight(initial: R, operation: (Byte, R) -> R)
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun ByteArray.reduce(operation: (Byte, Byte) -> Byte): Byte {
|
||||
val iterator = this.iterator()!!
|
||||
val iterator = this.iterator()
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +224,7 @@ public inline fun <K> ByteArray.groupByTo(result: MutableMap<K, MutableList<Byte
|
||||
public inline fun ByteArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()!!
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -132,9 +132,7 @@ public inline fun <C: MutableCollection<Char>> CharArray?.filterNotNullTo(result
|
||||
public inline fun <R> CharArray.flatMapTo(result: MutableCollection<R>, transform: (Char) -> Collection<R>) : Collection<R> {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
if (list != null) {
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -172,7 +170,7 @@ public inline fun <R> CharArray.foldRight(initial: R, operation: (Char, R) -> R)
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun CharArray.reduce(operation: (Char, Char) -> Char): Char {
|
||||
val iterator = this.iterator()!!
|
||||
val iterator = this.iterator()
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +224,7 @@ public inline fun <K> CharArray.groupByTo(result: MutableMap<K, MutableList<Char
|
||||
public inline fun CharArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()!!
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -132,9 +132,7 @@ public inline fun <C: MutableCollection<Double>> DoubleArray?.filterNotNullTo(re
|
||||
public inline fun <R> DoubleArray.flatMapTo(result: MutableCollection<R>, transform: (Double) -> Collection<R>) : Collection<R> {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
if (list != null) {
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -172,7 +170,7 @@ public inline fun <R> DoubleArray.foldRight(initial: R, operation: (Double, R) -
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun DoubleArray.reduce(operation: (Double, Double) -> Double): Double {
|
||||
val iterator = this.iterator()!!
|
||||
val iterator = this.iterator()
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +224,7 @@ public inline fun <K> DoubleArray.groupByTo(result: MutableMap<K, MutableList<Do
|
||||
public inline fun DoubleArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()!!
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -132,9 +132,7 @@ public inline fun <C: MutableCollection<Float>> FloatArray?.filterNotNullTo(resu
|
||||
public inline fun <R> FloatArray.flatMapTo(result: MutableCollection<R>, transform: (Float) -> Collection<R>) : Collection<R> {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
if (list != null) {
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -172,7 +170,7 @@ public inline fun <R> FloatArray.foldRight(initial: R, operation: (Float, R) ->
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun FloatArray.reduce(operation: (Float, Float) -> Float): Float {
|
||||
val iterator = this.iterator()!!
|
||||
val iterator = this.iterator()
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +224,7 @@ public inline fun <K> FloatArray.groupByTo(result: MutableMap<K, MutableList<Flo
|
||||
public inline fun FloatArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()!!
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -132,9 +132,7 @@ public inline fun <C: MutableCollection<Int>> IntArray?.filterNotNullTo(result:
|
||||
public inline fun <R> IntArray.flatMapTo(result: MutableCollection<R>, transform: (Int) -> Collection<R>) : Collection<R> {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
if (list != null) {
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -172,7 +170,7 @@ public inline fun <R> IntArray.foldRight(initial: R, operation: (Int, R) -> R):
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun IntArray.reduce(operation: (Int, Int) -> Int): Int {
|
||||
val iterator = this.iterator()!!
|
||||
val iterator = this.iterator()
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +224,7 @@ public inline fun <K> IntArray.groupByTo(result: MutableMap<K, MutableList<Int>>
|
||||
public inline fun IntArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()!!
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -131,9 +131,7 @@ public inline fun <T, C: MutableCollection<in T>> Iterator<T?>?.filterNotNullTo(
|
||||
public inline fun <T, R> Iterator<T>.flatMapTo(result: MutableCollection<R>, transform: (T) -> Collection<R>) : Collection<R> {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
if (list != null) {
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -171,7 +169,7 @@ public inline fun <T,R> Iterator<T>.foldRight(initial: R, operation: (T, R) -> R
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun <T> Iterator<T>.reduce(operation: (T, T) -> T): T {
|
||||
val iterator = this.iterator()!!
|
||||
val iterator = this.iterator()
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -225,7 +223,7 @@ public inline fun <T, K> Iterator<T>.groupByTo(result: MutableMap<K, MutableList
|
||||
public inline fun <T> Iterator<T>.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()!!
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -132,9 +132,7 @@ public inline fun <C: MutableCollection<Long>> LongArray?.filterNotNullTo(result
|
||||
public inline fun <R> LongArray.flatMapTo(result: MutableCollection<R>, transform: (Long) -> Collection<R>) : Collection<R> {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
if (list != null) {
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -172,7 +170,7 @@ public inline fun <R> LongArray.foldRight(initial: R, operation: (Long, R) -> R)
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun LongArray.reduce(operation: (Long, Long) -> Long): Long {
|
||||
val iterator = this.iterator()!!
|
||||
val iterator = this.iterator()
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +224,7 @@ public inline fun <K> LongArray.groupByTo(result: MutableMap<K, MutableList<Long
|
||||
public inline fun LongArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()!!
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -132,9 +132,7 @@ public inline fun <C: MutableCollection<Short>> ShortArray?.filterNotNullTo(resu
|
||||
public inline fun <R> ShortArray.flatMapTo(result: MutableCollection<R>, transform: (Short) -> Collection<R>) : Collection<R> {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
if (list != null) {
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -172,7 +170,7 @@ public inline fun <R> ShortArray.foldRight(initial: R, operation: (Short, R) ->
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun ShortArray.reduce(operation: (Short, Short) -> Short): Short {
|
||||
val iterator = this.iterator()!!
|
||||
val iterator = this.iterator()
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +224,7 @@ public inline fun <K> ShortArray.groupByTo(result: MutableMap<K, MutableList<Sho
|
||||
public inline fun ShortArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()!!
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -57,7 +57,7 @@ public inline fun FloatArray.fill(value: Float) : Unit = Arrays.fill(this,
|
||||
public inline fun DoubleArray.fill(value: Double) : Unit = Arrays.fill(this, value)
|
||||
public inline fun CharArray.fill(value: Char) : Unit = Arrays.fill(this, value)
|
||||
|
||||
public inline fun <in T: Any?> Array<T>.fill(value: T) : Unit = Arrays.fill(this as Array<Any?>, value)
|
||||
public inline fun <in T: Any?> Array<T>.fill(value: T) : Unit = Arrays.fill(this, value)
|
||||
|
||||
public inline fun ByteArray.sort() : Unit = Arrays.sort(this)
|
||||
public inline fun ShortArray.sort() : Unit = Arrays.sort(this)
|
||||
@@ -75,29 +75,29 @@ public inline fun FloatArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays
|
||||
public inline fun DoubleArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
|
||||
public inline fun CharArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex)
|
||||
|
||||
public inline fun BooleanArray.copyOf(newLength: Int = this.size) : BooleanArray = Arrays.copyOf(this, newLength)!!
|
||||
public inline fun ByteArray.copyOf(newLength: Int = this.size) : ByteArray = Arrays.copyOf(this, newLength)!!
|
||||
public inline fun ShortArray.copyOf(newLength: Int = this.size) : ShortArray = Arrays.copyOf(this, newLength)!!
|
||||
public inline fun IntArray.copyOf(newLength: Int = this.size) : IntArray = Arrays.copyOf(this, newLength)!!
|
||||
public inline fun LongArray.copyOf(newLength: Int = this.size) : LongArray = Arrays.copyOf(this, newLength)!!
|
||||
public inline fun FloatArray.copyOf(newLength: Int = this.size) : FloatArray = Arrays.copyOf(this, newLength)!!
|
||||
public inline fun DoubleArray.copyOf(newLength: Int = this.size) : DoubleArray = Arrays.copyOf(this, newLength)!!
|
||||
public inline fun CharArray.copyOf(newLength: Int = this.size) : CharArray = Arrays.copyOf(this, newLength)!!
|
||||
public inline fun BooleanArray.copyOf(newLength: Int = this.size) : BooleanArray = Arrays.copyOf(this, newLength)
|
||||
public inline fun ByteArray.copyOf(newLength: Int = this.size) : ByteArray = Arrays.copyOf(this, newLength)
|
||||
public inline fun ShortArray.copyOf(newLength: Int = this.size) : ShortArray = Arrays.copyOf(this, newLength)
|
||||
public inline fun IntArray.copyOf(newLength: Int = this.size) : IntArray = Arrays.copyOf(this, newLength)
|
||||
public inline fun LongArray.copyOf(newLength: Int = this.size) : LongArray = Arrays.copyOf(this, newLength)
|
||||
public inline fun FloatArray.copyOf(newLength: Int = this.size) : FloatArray = Arrays.copyOf(this, newLength)
|
||||
public inline fun DoubleArray.copyOf(newLength: Int = this.size) : DoubleArray = Arrays.copyOf(this, newLength)
|
||||
public inline fun CharArray.copyOf(newLength: Int = this.size) : CharArray = Arrays.copyOf(this, newLength)
|
||||
|
||||
// TODO: resuling array may contain nulls even if T is non-nullable
|
||||
public inline fun <T> Array<T>.copyOf(newLength: Int = this.size) : Array<T> = Arrays.copyOf(this as Array<T?>, newLength) as Array<T>
|
||||
public inline fun <T> Array<T>.copyOf(newLength: Int = this.size) : Array<T> = Arrays.copyOf(this, newLength) as Array<T>
|
||||
|
||||
public inline fun BooleanArray.copyOfRange(from: Int, to: Int) : BooleanArray = Arrays.copyOfRange(this, from, to)!!
|
||||
public inline fun ByteArray.copyOfRange(from: Int, to: Int) : ByteArray = Arrays.copyOfRange(this, from, to)!!
|
||||
public inline fun ShortArray.copyOfRange(from: Int, to: Int) : ShortArray = Arrays.copyOfRange(this, from, to)!!
|
||||
public inline fun IntArray.copyOfRange(from: Int, to: Int) : IntArray = Arrays.copyOfRange(this, from, to)!!
|
||||
public inline fun LongArray.copyOfRange(from: Int, to: Int) : LongArray = Arrays.copyOfRange(this, from, to)!!
|
||||
public inline fun FloatArray.copyOfRange(from: Int, to: Int) : FloatArray = Arrays.copyOfRange(this, from, to)!!
|
||||
public inline fun DoubleArray.copyOfRange(from: Int, to: Int) : DoubleArray = Arrays.copyOfRange(this, from, to)!!
|
||||
public inline fun CharArray.copyOfRange(from: Int, to: Int) : CharArray = Arrays.copyOfRange(this, from, to)!!
|
||||
public inline fun BooleanArray.copyOfRange(from: Int, to: Int) : BooleanArray = Arrays.copyOfRange(this, from, to)
|
||||
public inline fun ByteArray.copyOfRange(from: Int, to: Int) : ByteArray = Arrays.copyOfRange(this, from, to)
|
||||
public inline fun ShortArray.copyOfRange(from: Int, to: Int) : ShortArray = Arrays.copyOfRange(this, from, to)
|
||||
public inline fun IntArray.copyOfRange(from: Int, to: Int) : IntArray = Arrays.copyOfRange(this, from, to)
|
||||
public inline fun LongArray.copyOfRange(from: Int, to: Int) : LongArray = Arrays.copyOfRange(this, from, to)
|
||||
public inline fun FloatArray.copyOfRange(from: Int, to: Int) : FloatArray = Arrays.copyOfRange(this, from, to)
|
||||
public inline fun DoubleArray.copyOfRange(from: Int, to: Int) : DoubleArray = Arrays.copyOfRange(this, from, to)
|
||||
public inline fun CharArray.copyOfRange(from: Int, to: Int) : CharArray = Arrays.copyOfRange(this, from, to)
|
||||
|
||||
// TODO: resuling array may contain nulls even if T is non-nullable
|
||||
public inline fun <T> Array<T>.copyOfRange(from: Int, to: Int) : Array<T> = Arrays.copyOfRange(this as Array<T?>, from, to) as Array<T>
|
||||
public inline fun <T> Array<T>.copyOfRange(from: Int, to: Int) : Array<T> = Arrays.copyOfRange(this, from, to) as Array<T>
|
||||
|
||||
public inline val ByteArray.inputStream : ByteArrayInputStream
|
||||
get() = ByteArrayInputStream(this)
|
||||
|
||||
@@ -32,7 +32,7 @@ private class ImmutableArrayList<T>(
|
||||
return index + offset
|
||||
}
|
||||
|
||||
public override fun get(index: Int): T = array[indexInArray(index)] as T
|
||||
public override fun get(index: Int): T = array[indexInArray(index)]
|
||||
|
||||
public override fun size() : Int = length
|
||||
|
||||
|
||||
@@ -123,9 +123,7 @@ public inline fun <T, C: MutableCollection<in T>> Iterable<T?>?.filterNotNullTo(
|
||||
public inline fun <T, R> Iterable<T>.flatMapTo(result: MutableCollection<R>, transform: (T) -> Collection<R>) : Collection<R> {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
if (list != null) {
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
for (r in list) result.add(r)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -163,7 +161,7 @@ public inline fun <T,R> Iterable<T>.foldRight(initial: R, operation: (T, R) -> R
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun <T> Iterable<T>.reduce(operation: (T, T) -> T): T {
|
||||
val iterator = this.iterator()!!
|
||||
val iterator = this.iterator()
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -217,7 +215,7 @@ public inline fun <T, K> Iterable<T>.groupByTo(result: MutableMap<K, MutableList
|
||||
public inline fun <T> Iterable<T>.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||
val buffer = StringBuilder()
|
||||
appendString(buffer, separator, prefix, postfix, limit, truncated)
|
||||
return buffer.toString()!!
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -40,7 +40,7 @@ public inline fun <T> Iterable<T>.first() : T {
|
||||
return this.get(0)
|
||||
}
|
||||
|
||||
return this.iterator()!!.next()
|
||||
return this.iterator().next()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ public fun <T> Iterable<T>.last() : T {
|
||||
return this.get(this.size() - 1)
|
||||
}
|
||||
|
||||
val iterator = this.iterator()!!
|
||||
val iterator = this.iterator()
|
||||
var last : T = iterator.next()
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
|
||||
@@ -23,20 +23,20 @@ public inline fun <K,V> Map<K,V>?.orEmpty() : Map<K,V>
|
||||
|
||||
/** Returns the key of the entry */
|
||||
val <K,V> Map.Entry<K,V>.key : K
|
||||
get() = getKey()!!
|
||||
get() = getKey()
|
||||
|
||||
/** Returns the value of the entry */
|
||||
val <K,V> Map.Entry<K,V>.value : V
|
||||
get() = getValue()!!
|
||||
get() = getValue()
|
||||
|
||||
/** Returns the key of the entry */
|
||||
fun <K,V> Map.Entry<K,V>.component1() : K {
|
||||
return getKey()!!
|
||||
return getKey()
|
||||
}
|
||||
|
||||
/** Returns the value of the entry */
|
||||
fun <K,V> Map.Entry<K,V>.component2() : V {
|
||||
return getValue()!!
|
||||
return getValue()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,8 +74,8 @@ public inline fun <K,V> MutableMap<K,V>.getOrPut(key: K, defaultValue: ()-> V) :
|
||||
* @includeFunctionBody ../../test/MapTest.kt iterateWithProperties
|
||||
*/
|
||||
public inline fun <K,V> Map<K,V>.iterator(): Iterator<Map.Entry<K,V>> {
|
||||
val entrySet = this.entrySet()!!
|
||||
return entrySet.iterator()!!
|
||||
val entrySet = this.entrySet()
|
||||
return entrySet.iterator()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,7 @@ Helper to make java.util.Enumeration usable in for
|
||||
public fun <T> java.util.Enumeration<T>.iterator(): Iterator<T> = object: Iterator<T> {
|
||||
override fun hasNext(): Boolean = hasMoreElements()
|
||||
|
||||
public override fun next() : T = nextElement()!!
|
||||
public override fun next() : T = nextElement()
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -14,33 +14,33 @@ public inline fun String.indexOf(str : String) : Int = (this as java.lang.String
|
||||
|
||||
public inline fun String.indexOf(str : String, fromIndex : Int) : Int = (this as java.lang.String).indexOf(str, fromIndex)
|
||||
|
||||
public inline fun String.replace(oldChar: Char, newChar : Char) : String = (this as java.lang.String).replace(oldChar, newChar)!!
|
||||
public inline fun String.replace(oldChar: Char, newChar : Char) : String = (this as java.lang.String).replace(oldChar, newChar)
|
||||
|
||||
public inline fun String.replaceAll(regex: String, replacement : String) : String = (this as java.lang.String).replaceAll(regex, replacement)!!
|
||||
public inline fun String.replaceAll(regex: String, replacement : String) : String = (this as java.lang.String).replaceAll(regex, replacement)
|
||||
|
||||
public inline fun String.trim() : String = (this as java.lang.String).trim()!!
|
||||
public inline fun String.trim() : String = (this as java.lang.String).trim()
|
||||
|
||||
public inline fun String.toUpperCase() : String = (this as java.lang.String).toUpperCase()!!
|
||||
public inline fun String.toUpperCase() : String = (this as java.lang.String).toUpperCase()
|
||||
|
||||
public inline fun String.toLowerCase() : String = (this as java.lang.String).toLowerCase()!!
|
||||
public inline fun String.toLowerCase() : String = (this as java.lang.String).toLowerCase()
|
||||
|
||||
public inline fun String.length() : Int = (this as java.lang.String).length()
|
||||
|
||||
public inline fun String.getBytes() : ByteArray = (this as java.lang.String).getBytes()!!
|
||||
public inline fun String.getBytes() : ByteArray = (this as java.lang.String).getBytes()
|
||||
|
||||
public inline fun String.toCharArray() : CharArray = (this as java.lang.String).toCharArray()!!
|
||||
public inline fun String.toCharArray() : CharArray = (this as java.lang.String).toCharArray()
|
||||
|
||||
public inline fun String.toCharList(): List<Char> = toCharArray().toList()
|
||||
|
||||
public inline fun String.format(format : String, vararg args : Any?) : String = java.lang.String.format(format, args)!!
|
||||
public inline fun String.format(format : String, vararg args : Any?) : String = java.lang.String.format(format, args)
|
||||
|
||||
public inline fun String.split(regex : String) : Array<String> = (this as java.lang.String).split(regex) as Array<String>
|
||||
|
||||
public inline fun String.split(ch : Char) : Array<String> = (this as java.lang.String).split(java.util.regex.Pattern.quote(ch.toString())) as Array<String>
|
||||
|
||||
public inline fun String.substring(beginIndex : Int) : String = (this as java.lang.String).substring(beginIndex)!!
|
||||
public inline fun String.substring(beginIndex : Int) : String = (this as java.lang.String).substring(beginIndex)
|
||||
|
||||
public inline fun String.substring(beginIndex : Int, endIndex : Int) : String = (this as java.lang.String).substring(beginIndex, endIndex)!!
|
||||
public inline fun String.substring(beginIndex : Int, endIndex : Int) : String = (this as java.lang.String).substring(beginIndex, endIndex)
|
||||
|
||||
public inline fun String.startsWith(prefix: String) : Boolean = (this as java.lang.String).startsWith(prefix)
|
||||
|
||||
@@ -74,59 +74,59 @@ public inline fun String(stringBuffer : java.lang.StringBuffer) : String = java.
|
||||
|
||||
public inline fun String(stringBuilder : java.lang.StringBuilder) : String = java.lang.String(stringBuilder) as String
|
||||
|
||||
public inline fun String.replaceFirst(regex : String, replacement : String) : String = (this as java.lang.String).replaceFirst(regex, replacement)!!
|
||||
public inline fun String.replaceFirst(regex : String, replacement : String) : String = (this as java.lang.String).replaceFirst(regex, replacement)
|
||||
|
||||
public inline fun String.charAt(index : Int) : Char = (this as java.lang.String).charAt(index)!!
|
||||
public inline fun String.charAt(index : Int) : Char = (this as java.lang.String).charAt(index)
|
||||
|
||||
public inline fun String.split(regex : String, limit : Int) : Array<String> = (this as java.lang.String).split(regex, limit)
|
||||
|
||||
public inline fun String.codePointAt(index : Int) : Int = (this as java.lang.String).codePointAt(index)!!
|
||||
public inline fun String.codePointAt(index : Int) : Int = (this as java.lang.String).codePointAt(index)
|
||||
|
||||
public inline fun String.codePointBefore(index : Int) : Int = (this as java.lang.String).codePointBefore(index)!!
|
||||
public inline fun String.codePointBefore(index : Int) : Int = (this as java.lang.String).codePointBefore(index)
|
||||
|
||||
public inline fun String.codePointCount(beginIndex : Int, endIndex : Int) : Int = (this as java.lang.String).codePointCount(beginIndex, endIndex)
|
||||
|
||||
public inline fun String.compareToIgnoreCase(str : String) : Int = (this as java.lang.String).compareToIgnoreCase(str)!!
|
||||
public inline fun String.compareToIgnoreCase(str : String) : Int = (this as java.lang.String).compareToIgnoreCase(str)
|
||||
|
||||
public inline fun String.concat(str : String) : String = (this as java.lang.String).concat(str)!!
|
||||
public inline fun String.concat(str : String) : String = (this as java.lang.String).concat(str)
|
||||
|
||||
public inline fun String.contentEquals(cs : CharSequence) : Boolean = (this as java.lang.String).contentEquals(cs)!!
|
||||
public inline fun String.contentEquals(cs : CharSequence) : Boolean = (this as java.lang.String).contentEquals(cs)
|
||||
|
||||
public inline fun String.contentEquals(sb : StringBuffer) : Boolean = (this as java.lang.String).contentEquals(sb)!!
|
||||
public inline fun String.contentEquals(sb : StringBuffer) : Boolean = (this as java.lang.String).contentEquals(sb)
|
||||
|
||||
public inline fun String.getBytes(charset : java.nio.charset.Charset) : ByteArray = (this as java.lang.String).getBytes(charset)!!
|
||||
public inline fun String.getBytes(charset : java.nio.charset.Charset) : ByteArray = (this as java.lang.String).getBytes(charset)
|
||||
|
||||
public inline fun String.getBytes(charsetName : String) : ByteArray = (this as java.lang.String).getBytes(charsetName)!!
|
||||
public inline fun String.getBytes(charsetName : String) : ByteArray = (this as java.lang.String).getBytes(charsetName)
|
||||
|
||||
public inline fun String.getChars(srcBegin : Int, srcEnd : Int, dst : CharArray, dstBegin : Int) : Tuple0 = (this as java.lang.String).getChars(srcBegin, srcEnd, dst, dstBegin)!!
|
||||
public inline fun String.getChars(srcBegin : Int, srcEnd : Int, dst : CharArray, dstBegin : Int) : Tuple0 = (this as java.lang.String).getChars(srcBegin, srcEnd, dst, dstBegin)
|
||||
|
||||
public inline fun String.indexOf(ch : Char) : Int = (this as java.lang.String).indexOf(ch.toString())!!
|
||||
public inline fun String.indexOf(ch : Char) : Int = (this as java.lang.String).indexOf(ch.toString())
|
||||
|
||||
public inline fun String.indexOf(ch : Char, fromIndex : Int) : Int = (this as java.lang.String).indexOf(ch.toString(), fromIndex)!!
|
||||
public inline fun String.indexOf(ch : Char, fromIndex : Int) : Int = (this as java.lang.String).indexOf(ch.toString(), fromIndex)
|
||||
|
||||
public inline fun String.intern() : String = (this as java.lang.String).intern()!!
|
||||
public inline fun String.intern() : String = (this as java.lang.String).intern()
|
||||
|
||||
public inline fun String.isEmpty() : Boolean = (this as java.lang.String).isEmpty()!!
|
||||
public inline fun String.isEmpty() : Boolean = (this as java.lang.String).isEmpty()
|
||||
|
||||
public inline fun String.lastIndexOf(ch : Char, fromIndex : Int) : Int = (this as java.lang.String).lastIndexOf(ch.toString(), fromIndex)!!
|
||||
public inline fun String.lastIndexOf(ch : Char, fromIndex : Int) : Int = (this as java.lang.String).lastIndexOf(ch.toString(), fromIndex)
|
||||
|
||||
public inline fun String.lastIndexOf(str : String, fromIndex : Int) : Int = (this as java.lang.String).lastIndexOf(str, fromIndex)!!
|
||||
public inline fun String.lastIndexOf(str : String, fromIndex : Int) : Int = (this as java.lang.String).lastIndexOf(str, fromIndex)
|
||||
|
||||
public inline fun String.matches(regex : String) : Boolean = (this as java.lang.String).matches(regex)!!
|
||||
public inline fun String.matches(regex : String) : Boolean = (this as java.lang.String).matches(regex)
|
||||
|
||||
public inline fun String.offsetByCodePoints(index : Int, codePointOffset : Int) : Int = (this as java.lang.String).offsetByCodePoints(index, codePointOffset)!!
|
||||
public inline fun String.offsetByCodePoints(index : Int, codePointOffset : Int) : Int = (this as java.lang.String).offsetByCodePoints(index, codePointOffset)
|
||||
|
||||
public inline fun String.regionMatches(ignoreCase : Boolean, toffset : Int, other : String, ooffset : Int, len : Int) : Boolean = (this as java.lang.String).regionMatches(ignoreCase, toffset, other, ooffset, len)!!
|
||||
public inline fun String.regionMatches(ignoreCase : Boolean, toffset : Int, other : String, ooffset : Int, len : Int) : Boolean = (this as java.lang.String).regionMatches(ignoreCase, toffset, other, ooffset, len)
|
||||
|
||||
public inline fun String.regionMatches(toffset : Int, other : String, ooffset : Int, len : Int) : Boolean = (this as java.lang.String).regionMatches(toffset, other, ooffset, len)!!
|
||||
public inline fun String.regionMatches(toffset : Int, other : String, ooffset : Int, len : Int) : Boolean = (this as java.lang.String).regionMatches(toffset, other, ooffset, len)
|
||||
|
||||
public inline fun String.replace(target : CharSequence, replacement : CharSequence) : String = (this as java.lang.String).replace(target, replacement)!!
|
||||
public inline fun String.replace(target : CharSequence, replacement : CharSequence) : String = (this as java.lang.String).replace(target, replacement)
|
||||
|
||||
public inline fun String.subSequence(beginIndex : Int, endIndex : Int) : CharSequence = (this as java.lang.String).subSequence(beginIndex, endIndex)!!
|
||||
public inline fun String.subSequence(beginIndex : Int, endIndex : Int) : CharSequence = (this as java.lang.String).subSequence(beginIndex, endIndex)
|
||||
|
||||
public inline fun String.toLowerCase(locale : java.util.Locale) : String = (this as java.lang.String).toLowerCase(locale)!!
|
||||
public inline fun String.toLowerCase(locale : java.util.Locale) : String = (this as java.lang.String).toLowerCase(locale)
|
||||
|
||||
public inline fun String.toUpperCase(locale : java.util.Locale) : String = (this as java.lang.String).toUpperCase(locale)!!
|
||||
public inline fun String.toUpperCase(locale : java.util.Locale) : String = (this as java.lang.String).toUpperCase(locale)
|
||||
|
||||
|
||||
public inline fun CharSequence.charAt(index : Int) : Char = (this as java.lang.CharSequence).charAt(index)
|
||||
@@ -144,19 +144,19 @@ public inline fun CharSequence.length() : Int = (this as java.lang.CharSequence)
|
||||
|
||||
public inline fun String.toByteArray(encoding: String?=null):ByteArray {
|
||||
if(encoding==null) {
|
||||
return (this as java.lang.String).getBytes()!!
|
||||
return (this as java.lang.String).getBytes()
|
||||
} else {
|
||||
return (this as java.lang.String).getBytes(encoding)!!
|
||||
return (this as java.lang.String).getBytes(encoding)
|
||||
}
|
||||
}
|
||||
public inline fun String.toByteArray(encoding: java.nio.charset.Charset):ByteArray = (this as java.lang.String).getBytes(encoding)!!
|
||||
public inline fun String.toByteArray(encoding: java.nio.charset.Charset):ByteArray = (this as java.lang.String).getBytes(encoding)
|
||||
|
||||
public inline fun String.toBoolean() : Boolean = java.lang.Boolean.parseBoolean(this)!!
|
||||
public inline fun String.toShort() : Short = java.lang.Short.parseShort(this)!!
|
||||
public inline fun String.toInt() : Int = java.lang.Integer.parseInt(this)!!
|
||||
public inline fun String.toLong() : Long = java.lang.Long.parseLong(this)!!
|
||||
public inline fun String.toFloat() : Float = java.lang.Float.parseFloat(this)!!
|
||||
public inline fun String.toDouble() : Double = java.lang.Double.parseDouble(this)!!
|
||||
public inline fun String.toBoolean() : Boolean = java.lang.Boolean.parseBoolean(this)
|
||||
public inline fun String.toShort() : Short = java.lang.Short.parseShort(this)
|
||||
public inline fun String.toInt() : Int = java.lang.Integer.parseInt(this)
|
||||
public inline fun String.toLong() : Long = java.lang.Long.parseLong(this)
|
||||
public inline fun String.toFloat() : Float = java.lang.Float.parseFloat(this)
|
||||
public inline fun String.toDouble() : Double = java.lang.Double.parseDouble(this)
|
||||
|
||||
/**
|
||||
* Converts the string into a regular expression [[Pattern]] optionally
|
||||
@@ -164,7 +164,7 @@ public inline fun String.toDouble() : Double = java.lang.Double.parseDouble(this
|
||||
* so that strings can be split or matched on.
|
||||
*/
|
||||
public inline fun String.toRegex(flags: Int=0): java.util.regex.Pattern {
|
||||
return java.util.regex.Pattern.compile(this, flags)!!
|
||||
return java.util.regex.Pattern.compile(this, flags)
|
||||
}
|
||||
|
||||
inline val String.reader : StringReader
|
||||
|
||||
@@ -11,8 +11,8 @@ import java.lang.IndexOutOfBoundsException
|
||||
|
||||
// Properties
|
||||
|
||||
private fun emptyElementList(): List<Element> = Collections.emptyList<Element>()!!
|
||||
private fun emptyNodeList(): List<Node> = Collections.emptyList<Node>()!!
|
||||
private fun emptyElementList(): List<Element> = Collections.emptyList<Element>()
|
||||
private fun emptyNodeList(): List<Node> = Collections.emptyList<Node>()
|
||||
|
||||
var Node.text : String
|
||||
get() {
|
||||
@@ -26,23 +26,21 @@ var Element.childrenText: String
|
||||
get() {
|
||||
val buffer = StringBuilder()
|
||||
val nodeList = this.childNodes
|
||||
if (nodeList != null) {
|
||||
var i = 0
|
||||
val size = nodeList.length
|
||||
while (i < size) {
|
||||
val node = nodeList.item(i)
|
||||
if (node != null) {
|
||||
if (node.isText()) {
|
||||
buffer.append(node.nodeValue)
|
||||
}
|
||||
var i = 0
|
||||
val size = nodeList.length
|
||||
while (i < size) {
|
||||
val node = nodeList.item(i)
|
||||
if (node != null) {
|
||||
if (node.isText()) {
|
||||
buffer.append(node.nodeValue)
|
||||
}
|
||||
i++
|
||||
}
|
||||
i++
|
||||
}
|
||||
return buffer.toString()!!
|
||||
return buffer.toString()
|
||||
}
|
||||
set(value) {
|
||||
val element = this as Element
|
||||
val element = this
|
||||
// lets remove all the previous text nodes first
|
||||
for (node in element.children()) {
|
||||
if (node.isText()) {
|
||||
@@ -74,9 +72,7 @@ set(value) {
|
||||
/** Returns true if the element has the given CSS class style in its 'class' attribute */
|
||||
fun Element.hasClass(cssClass: String): Boolean {
|
||||
val c = this.classes
|
||||
return if (c != null)
|
||||
c.matches("""(^|.*\s+)$cssClass($|\s+.*)""")
|
||||
else false
|
||||
return c.matches("""(^|.*\s+)$cssClass($|\s+.*)""")
|
||||
}
|
||||
|
||||
|
||||
@@ -341,7 +337,7 @@ public fun nodesToXmlString(nodes: Iterable<Node>, xmlDeclaration: Boolean = fal
|
||||
for (n in nodes) {
|
||||
builder.append(n.toXmlString(xmlDeclaration))
|
||||
}
|
||||
return builder.toString()!!
|
||||
return builder.toString()
|
||||
}
|
||||
|
||||
// Syntax sugar
|
||||
|
||||
@@ -54,7 +54,7 @@ val Node.ownerDocument: Document?
|
||||
get() = getOwnerDocument()
|
||||
|
||||
val Document.documentElement: Element?
|
||||
get() = if (this != null) this.getDocumentElement() else null
|
||||
get() = this.getDocumentElement()
|
||||
|
||||
val Node.namespaceURI: String
|
||||
get() = getNamespaceURI() ?: ""
|
||||
@@ -123,7 +123,7 @@ get() {
|
||||
val answer = LinkedHashSet<String>()
|
||||
val array = this.classes.split("""\s""")
|
||||
for (s in array) {
|
||||
if (s != null && s.size > 0) {
|
||||
if (s.size > 0) {
|
||||
answer.add(s)
|
||||
}
|
||||
}
|
||||
@@ -225,7 +225,7 @@ public fun Node.toXmlString(): String = toXmlString(false)
|
||||
public fun Node.toXmlString(xmlDeclaration: Boolean): String {
|
||||
val writer = StringWriter()
|
||||
writeXmlString(writer, xmlDeclaration)
|
||||
return writer.toString()!!
|
||||
return writer.toString()
|
||||
}
|
||||
|
||||
/** Converts the node to an XML String and writes it to the given [[Writer]] */
|
||||
|
||||
@@ -14,9 +14,7 @@ public fun File.recurse(block: (File) -> Unit): Unit {
|
||||
block(this)
|
||||
if (this.isDirectory()) {
|
||||
for (child in this.listFiles()!!) {
|
||||
if (child != null) {
|
||||
child.recurse(block)
|
||||
}
|
||||
child.recurse(block)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,19 +29,19 @@ get() = if (this.isDirectory()) this else this.getParentFile()!!
|
||||
* Returns the canoncial path of the file
|
||||
*/
|
||||
inline val File.canonicalPath: String
|
||||
get() = getCanonicalPath() ?: ""
|
||||
get() = getCanonicalPath()
|
||||
|
||||
/**
|
||||
* Returns the file name or "" for an empty name
|
||||
*/
|
||||
inline val File.name: String
|
||||
get() = getName() ?: ""
|
||||
get() = getName()
|
||||
|
||||
/**
|
||||
* Returns the file path or "" for an empty name
|
||||
*/
|
||||
inline val File.path: String
|
||||
get() = getPath() ?: ""
|
||||
get() = getPath()
|
||||
|
||||
/**
|
||||
* Returns true if the file ends with the given extension
|
||||
@@ -212,4 +210,4 @@ fun File.listFiles(filter : (file : File) -> Boolean) : Array<File>? = listFiles
|
||||
object : FileFilter {
|
||||
override fun accept(file: File) = filter(file)
|
||||
}
|
||||
) as Array<File>?
|
||||
)
|
||||
|
||||
@@ -18,125 +18,125 @@ public val defaultCharset: Charset = Charset.forName("UTF-8")!!
|
||||
|
||||
/** Prints the given message to [[System.out]] */
|
||||
public inline fun print(message : Any?) {
|
||||
System.out?.print(message)
|
||||
System.out.print(message)
|
||||
}
|
||||
/** Prints the given message to [[System.out]] */
|
||||
public inline fun print(message : Int) {
|
||||
System.out?.print(message)
|
||||
System.out.print(message)
|
||||
}
|
||||
/** Prints the given message to [[System.out]] */
|
||||
public inline fun print(message : Long) {
|
||||
System.out?.print(message)
|
||||
System.out.print(message)
|
||||
}
|
||||
/** Prints the given message to [[System.out]] */
|
||||
public inline fun print(message : Byte) {
|
||||
System.out?.print(message)
|
||||
System.out.print(message)
|
||||
}
|
||||
/** Prints the given message to [[System.out]] */
|
||||
public inline fun print(message : Short) {
|
||||
System.out?.print(message)
|
||||
System.out.print(message)
|
||||
}
|
||||
/** Prints the given message to [[System.out]] */
|
||||
public inline fun print(message : Char) {
|
||||
System.out?.print(message)
|
||||
System.out.print(message)
|
||||
}
|
||||
/** Prints the given message to [[System.out]] */
|
||||
public inline fun print(message : Boolean) {
|
||||
System.out?.print(message)
|
||||
System.out.print(message)
|
||||
}
|
||||
/** Prints the given message to [[System.out]] */
|
||||
public inline fun print(message : Float) {
|
||||
System.out?.print(message)
|
||||
System.out.print(message)
|
||||
}
|
||||
/** Prints the given message to [[System.out]] */
|
||||
public inline fun print(message : Double) {
|
||||
System.out?.print(message)
|
||||
System.out.print(message)
|
||||
}
|
||||
/** Prints the given message to [[System.out]] */
|
||||
public inline fun print(message : CharArray) {
|
||||
System.out?.print(message)
|
||||
System.out.print(message)
|
||||
}
|
||||
|
||||
/** Prints the given message and newline to [[System.out]] */
|
||||
public inline fun println(message : Any?) {
|
||||
System.out?.println(message)
|
||||
System.out.println(message)
|
||||
}
|
||||
/** Prints the given message and newline to [[System.out]] */
|
||||
public inline fun println(message : Int) {
|
||||
System.out?.println(message)
|
||||
System.out.println(message)
|
||||
}
|
||||
/** Prints the given message and newline to [[System.out]] */
|
||||
public inline fun println(message : Long) {
|
||||
System.out?.println(message)
|
||||
System.out.println(message)
|
||||
}
|
||||
/** Prints the given message and newline to [[System.out]] */
|
||||
public inline fun println(message : Byte) {
|
||||
System.out?.println(message)
|
||||
System.out.println(message)
|
||||
}
|
||||
/** Prints the given message and newline to [[System.out]] */
|
||||
public inline fun println(message : Short) {
|
||||
System.out?.println(message)
|
||||
System.out.println(message)
|
||||
}
|
||||
/** Prints the given message and newline to [[System.out]] */
|
||||
public inline fun println(message : Char) {
|
||||
System.out?.println(message)
|
||||
System.out.println(message)
|
||||
}
|
||||
/** Prints the given message and newline to [[System.out]] */
|
||||
public inline fun println(message : Boolean) {
|
||||
System.out?.println(message)
|
||||
System.out.println(message)
|
||||
}
|
||||
/** Prints the given message and newline to [[System.out]] */
|
||||
public inline fun println(message : Float) {
|
||||
System.out?.println(message)
|
||||
System.out.println(message)
|
||||
}
|
||||
/** Prints the given message and newline to [[System.out]] */
|
||||
public inline fun println(message : Double) {
|
||||
System.out?.println(message)
|
||||
System.out.println(message)
|
||||
}
|
||||
/** Prints the given message and newline to [[System.out]] */
|
||||
public inline fun println(message : CharArray) {
|
||||
System.out?.println(message)
|
||||
System.out.println(message)
|
||||
}
|
||||
/** Prints a newline t[[System.out]] */
|
||||
public inline fun println() {
|
||||
System.out?.println()
|
||||
System.out.println()
|
||||
}
|
||||
|
||||
private val stdin : BufferedReader = BufferedReader(InputStreamReader(object : InputStream() {
|
||||
public override fun read() : Int {
|
||||
return System.`in`?.read() ?: -1
|
||||
return System.`in`.read()
|
||||
}
|
||||
|
||||
public override fun reset() {
|
||||
System.`in`?.reset()
|
||||
System.`in`.reset()
|
||||
}
|
||||
|
||||
public override fun read(b: ByteArray): Int {
|
||||
return System.`in`?.read(b) ?: -1
|
||||
return System.`in`.read(b)
|
||||
}
|
||||
|
||||
public override fun close() {
|
||||
System.`in`?.close()
|
||||
System.`in`.close()
|
||||
}
|
||||
|
||||
public override fun mark(readlimit: Int) {
|
||||
System.`in`?.mark(readlimit)
|
||||
System.`in`.mark(readlimit)
|
||||
}
|
||||
|
||||
public override fun skip(n: Long): Long {
|
||||
return System.`in`?.skip(n) ?: -1.toLong()
|
||||
return System.`in`.skip(n)
|
||||
}
|
||||
|
||||
public override fun available(): Int {
|
||||
return System.`in`?.available() ?: 0
|
||||
return System.`in`.available()
|
||||
}
|
||||
|
||||
public override fun markSupported(): Boolean {
|
||||
return System.`in`?.markSupported() ?: false
|
||||
return System.`in`.markSupported()
|
||||
}
|
||||
|
||||
public override fun read(b: ByteArray, off: Int, len: Int): Int {
|
||||
return System.`in`?.read(b, off, len) ?: -1
|
||||
return System.`in`.read(b, off, len)
|
||||
}
|
||||
}))
|
||||
|
||||
@@ -266,7 +266,7 @@ class LineIterator(val reader: BufferedReader) : Iterator<String> {
|
||||
public fun InputStream.readBytes(estimatedSize: Int = defaultBufferSize): ByteArray {
|
||||
val buffer = ByteArrayOutputStream(estimatedSize)
|
||||
this.copyTo(buffer)
|
||||
return buffer.toByteArray()!!
|
||||
return buffer.toByteArray()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,7 +277,7 @@ public fun InputStream.readBytes(estimatedSize: Int = defaultBufferSize): ByteAr
|
||||
public fun Reader.readText(): String {
|
||||
val buffer = StringWriter()
|
||||
copyTo(buffer)
|
||||
return buffer.toString()!!
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,25 +3,25 @@ package kotlin.math
|
||||
import java.math.BigInteger
|
||||
import java.math.BigDecimal
|
||||
|
||||
public fun BigInteger.plus(other: BigInteger) : BigInteger = this.add(other)!!
|
||||
public fun BigInteger.plus(other: BigInteger) : BigInteger = this.add(other)
|
||||
|
||||
public fun BigInteger.minus(other: BigInteger) : BigInteger = this.subtract(other)!!
|
||||
public fun BigInteger.minus(other: BigInteger) : BigInteger = this.subtract(other)
|
||||
|
||||
public fun BigInteger.times(other: BigInteger) : BigInteger = this.multiply(other)!!
|
||||
public fun BigInteger.times(other: BigInteger) : BigInteger = this.multiply(other)
|
||||
|
||||
public fun BigInteger.div(other: BigInteger) : BigInteger = this.divide(other)!!
|
||||
public fun BigInteger.div(other: BigInteger) : BigInteger = this.divide(other)
|
||||
|
||||
public fun BigInteger.minus() : BigInteger = this.negate()!!
|
||||
public fun BigInteger.minus() : BigInteger = this.negate()
|
||||
|
||||
|
||||
public fun BigDecimal.plus(other: BigDecimal) : BigDecimal = this.add(other)!!
|
||||
public fun BigDecimal.plus(other: BigDecimal) : BigDecimal = this.add(other)
|
||||
|
||||
public fun BigDecimal.minus(other: BigDecimal) : BigDecimal = this.subtract(other)!!
|
||||
public fun BigDecimal.minus(other: BigDecimal) : BigDecimal = this.subtract(other)
|
||||
|
||||
public fun BigDecimal.times(other: BigDecimal) : BigDecimal = this.multiply(other)!!
|
||||
public fun BigDecimal.times(other: BigDecimal) : BigDecimal = this.multiply(other)
|
||||
|
||||
public fun BigDecimal.div(other: BigDecimal) : BigDecimal = this.divide(other)!!
|
||||
public fun BigDecimal.div(other: BigDecimal) : BigDecimal = this.divide(other)
|
||||
|
||||
public fun BigDecimal.mod(other: BigDecimal) : BigDecimal = this.remainder(other)!!
|
||||
public fun BigDecimal.mod(other: BigDecimal) : BigDecimal = this.remainder(other)
|
||||
|
||||
public fun BigDecimal.minus() : BigDecimal = this.negate()!!
|
||||
public fun BigDecimal.minus() : BigDecimal = this.negate()
|
||||
@@ -6,7 +6,7 @@ import jet.modules.*
|
||||
public fun module(name: String, callback: ModuleBuilder.() -> Unit) {
|
||||
val builder = ModuleBuilder(name)
|
||||
builder.callback()
|
||||
AllModules.modules!!.get()?.add(builder)
|
||||
AllModules.modules.get()?.add(builder)
|
||||
}
|
||||
|
||||
class SourcesBuilder(val parent: ModuleBuilder) {
|
||||
|
||||
@@ -69,10 +69,8 @@ public inline fun <T: Any, R> T?.flatMap(transform: (T)-> MutableCollection<R>):
|
||||
public inline fun <T: Any, R> T?.flatMapTo(result: MutableCollection<R>, transform: (T)-> MutableCollection<R>): Collection<R> {
|
||||
if (this != null) {
|
||||
val coll = transform(this)
|
||||
if (coll != null) {
|
||||
for (r in coll) {
|
||||
result.add(r)
|
||||
}
|
||||
for (r in coll) {
|
||||
result.add(r)
|
||||
}
|
||||
}
|
||||
return result
|
||||
@@ -124,7 +122,6 @@ public inline fun <T: Any, K> T?.groupBy(result: MutableMap<K, MutableList<T>> =
|
||||
/** Creates a String from the nullable or item with the given prefix and postfix if supplied */
|
||||
public inline fun <T: Any> T?.makeString(separator: String = ", ", prefix: String = "", postfix: String = ""): String {
|
||||
val buffer = StringBuilder(prefix)
|
||||
var first = true
|
||||
if (this != null) {
|
||||
buffer.append(this)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class StringTemplate(val values : Array<Any?>) {
|
||||
public fun toString() : String {
|
||||
val out = StringBuilder()
|
||||
forEach{ out.append(it) }
|
||||
return out.toString() ?: ""
|
||||
return out.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,7 +41,7 @@ class StringTemplate(val values : Array<Any?>) {
|
||||
public fun StringTemplate.toString(formatter : Formatter) : String {
|
||||
val buffer = StringBuilder()
|
||||
append(buffer, formatter)
|
||||
return buffer.toString() ?: ""
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,9 +56,7 @@ public fun StringTemplate.append(out : Appendable, formatter : Formatter) : Unit
|
||||
throw IllegalStateException("No constant checks should be null");
|
||||
} else {
|
||||
val text = it.toString()
|
||||
if (text != null) {
|
||||
out.append(text)
|
||||
}
|
||||
out.append(text)
|
||||
}
|
||||
} else {
|
||||
formatter.format(out, it)
|
||||
|
||||
@@ -65,7 +65,6 @@ class DefaultAsserter() : Asserter {
|
||||
}
|
||||
}
|
||||
public override fun fail(message : String) {
|
||||
// TODO work around compiler bug as it should never try call the private constructor
|
||||
throw AssertionError(message as Any)
|
||||
throw AssertionError(message)
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ class CollectionTest {
|
||||
assertEquals(4, byLength.size())
|
||||
|
||||
val l3 = byLength.getOrElse(3, {ArrayList<String>()})
|
||||
assertEquals(2, l3?.size)
|
||||
assertEquals(2, l3.size)
|
||||
}
|
||||
|
||||
test fun makeString() {
|
||||
|
||||
@@ -11,13 +11,13 @@ import junit.framework.TestCase
|
||||
class OldStdlibTest() : TestCase() {
|
||||
fun testCollectionEmpty() {
|
||||
assertNot {
|
||||
Arrays.asList(0, 1, 2)?.empty ?: false
|
||||
Arrays.asList(0, 1, 2).empty
|
||||
}
|
||||
}
|
||||
|
||||
fun testCollectionSize() {
|
||||
assertTrue {
|
||||
Arrays.asList(0, 1, 2)?.size == 3
|
||||
Arrays.asList(0, 1, 2).size == 3
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class OldStdlibTest() : TestCase() {
|
||||
}
|
||||
|
||||
for(b in x.inputStream) {
|
||||
System.out?.println(b)
|
||||
System.out.println(b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ class PairTest {
|
||||
assertTrue(p == Pair(1, "a"))
|
||||
assertTrue(p != Pair(2, "a"))
|
||||
assertTrue(p != Pair(1, "b"))
|
||||
assertTrue(!(p as Object).equals(null))
|
||||
assertTrue((p as Any) != "")
|
||||
assertTrue(!(p : Object).equals(null))
|
||||
assertTrue((p : Any) != "")
|
||||
}
|
||||
|
||||
test fun pairHashCode() {
|
||||
@@ -70,8 +70,8 @@ class TripleTest {
|
||||
assertTrue(t != Triple(2, "a", 0.0))
|
||||
assertTrue(t != Triple(1, "b", 0.0))
|
||||
assertTrue(t != Triple(1, "a", 0.1))
|
||||
assertTrue(!(t as Object).equals(null))
|
||||
assertTrue((t as Any) != "")
|
||||
assertTrue(!(t : Object).equals(null))
|
||||
assertTrue((t : Any) != "")
|
||||
}
|
||||
|
||||
test fun tripleHashCode() {
|
||||
|
||||
Reference in New Issue
Block a user