Replaced sure() invocations with '!!' operator in libraries written on Kotlin.
This commit is contained in:
@@ -29,7 +29,7 @@ class SiteGenerator(val sourceDir: File, val outputDir: File) : Runnable {
|
||||
val outFile = File(outputDir, relativePath)
|
||||
outFile.directory.mkdirs()
|
||||
if (output != null) {
|
||||
val text = layout(relativePath, it, output.sure())
|
||||
val text = layout(relativePath, it, output!!)
|
||||
outFile.writeText(text)
|
||||
} else {
|
||||
it.copyTo(outFile)
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.Properties
|
||||
/**
|
||||
* create connection for the specified jdbc url with no credentials
|
||||
*/
|
||||
fun getConnection(url : String) : Connection = DriverManager.getConnection(url).sure()
|
||||
fun getConnection(url : String) : Connection = DriverManager.getConnection(url)!!
|
||||
|
||||
/**
|
||||
* create connection for the specified jdbc url and properties
|
||||
|
||||
@@ -47,7 +47,7 @@ fun <T> ResultSet.map(fn : (ResultSet) -> T) : jet.Iterable<T> {
|
||||
* Returns array with column names
|
||||
*/
|
||||
fun ResultSet.getColumnNames() : jet.Array<String> {
|
||||
val meta = getMetaData().sure()
|
||||
val meta = getMetaData()!!
|
||||
return jet.Array<String>(meta.getColumnCount(), {meta.getColumnName(it + 1) ?: it.toString()})
|
||||
}
|
||||
|
||||
|
||||
@@ -25,25 +25,25 @@ var JFrame.contentPane: Container?
|
||||
}
|
||||
|
||||
var JFrame.title: String
|
||||
get() = getTitle().sure()
|
||||
get() = getTitle()!!
|
||||
set(t) {
|
||||
setTitle(t)
|
||||
}
|
||||
|
||||
var JFrame.size: Pair<Int, Int>
|
||||
get() = Pair(getSize().sure().getWidth().toInt(), getSize().sure().getHeight().toInt())
|
||||
get() = Pair(getSize()!!.getWidth().toInt(), getSize()!!.getHeight().toInt())
|
||||
set(dim) {
|
||||
setSize(Dimension(dim.first, dim.second))
|
||||
}
|
||||
|
||||
var JFrame.height: Int
|
||||
get() = getSize().sure().getHeight().toInt()
|
||||
get() = getSize()!!.getHeight().toInt()
|
||||
set(h) {
|
||||
setSize(width, h)
|
||||
}
|
||||
|
||||
var JFrame.width: Int
|
||||
get() = getSize().sure().getWidth().toInt()
|
||||
get() = getSize()!!.getWidth().toInt()
|
||||
set(w) {
|
||||
setSize(height, w)
|
||||
}
|
||||
|
||||
@@ -102,14 +102,14 @@ public abstract class AbstractIterator<T>: Iterator<T> {
|
||||
override fun next(): T {
|
||||
if (!hasNext) throw NoSuchElementException()
|
||||
state = State.NotReady
|
||||
return next.sure()
|
||||
return next!!
|
||||
}
|
||||
|
||||
|
||||
/** Returns the next element in the iteration without advancing the iteration */
|
||||
fun peek(): T {
|
||||
if (!hasNext) throw NoSuchElementException()
|
||||
return next.sure();
|
||||
return next!!;
|
||||
}
|
||||
|
||||
private fun tryToComputeNext(): Boolean {
|
||||
|
||||
@@ -201,7 +201,7 @@ public trait Traversable<T>: Iterable<T> {
|
||||
public inline fun 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().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -65,7 +65,7 @@ abstract class Tag(val name : String) : Element() {
|
||||
fun toString(): String {
|
||||
val builder = StringBuilder()
|
||||
appendTo(builder)
|
||||
return builder.toString().sure()
|
||||
return builder.toString()!!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class WriterPrinter(val writer: Writer) : Printer {
|
||||
fun Template.renderToText(): String {
|
||||
val buffer = StringWriter()
|
||||
renderTo(buffer)
|
||||
return buffer.toString().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
|
||||
fun Template.renderTo(writer: Writer): Unit {
|
||||
|
||||
@@ -172,7 +172,7 @@ public inline fun <T> Array<T>.foldRight(initial: T, operation: (T, T) -> T): T
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun <T> Array<T>.reduce(operation: (T, T) -> T): T {
|
||||
val iterator = this.iterator().sure()
|
||||
val iterator = this.iterator()!!
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +226,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().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -172,7 +172,7 @@ public inline fun BooleanArray.foldRight(initial: Boolean, operation: (Boolean,
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun BooleanArray.reduce(operation: (Boolean, Boolean) -> Boolean): Boolean {
|
||||
val iterator = this.iterator().sure()
|
||||
val iterator = this.iterator()!!
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +226,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().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -172,7 +172,7 @@ public inline fun ByteArray.foldRight(initial: Byte, operation: (Byte, Byte) ->
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun ByteArray.reduce(operation: (Byte, Byte) -> Byte): Byte {
|
||||
val iterator = this.iterator().sure()
|
||||
val iterator = this.iterator()!!
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +226,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().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -172,7 +172,7 @@ public inline fun CharArray.foldRight(initial: Char, operation: (Char, Char) ->
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun CharArray.reduce(operation: (Char, Char) -> Char): Char {
|
||||
val iterator = this.iterator().sure()
|
||||
val iterator = this.iterator()!!
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +226,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().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -172,7 +172,7 @@ public inline fun DoubleArray.foldRight(initial: Double, operation: (Double, Dou
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun DoubleArray.reduce(operation: (Double, Double) -> Double): Double {
|
||||
val iterator = this.iterator().sure()
|
||||
val iterator = this.iterator()!!
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +226,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().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -172,7 +172,7 @@ public inline fun FloatArray.foldRight(initial: Float, operation: (Float, Float)
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun FloatArray.reduce(operation: (Float, Float) -> Float): Float {
|
||||
val iterator = this.iterator().sure()
|
||||
val iterator = this.iterator()!!
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +226,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().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -172,7 +172,7 @@ public inline fun IntArray.foldRight(initial: Int, operation: (Int, Int) -> Int)
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun IntArray.reduce(operation: (Int, Int) -> Int): Int {
|
||||
val iterator = this.iterator().sure()
|
||||
val iterator = this.iterator()!!
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +226,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().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -171,7 +171,7 @@ public inline fun <T> Iterator<T>.foldRight(initial: T, operation: (T, T) -> T):
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun <T> Iterator<T>.reduce(operation: (T, T) -> T): T {
|
||||
val iterator = this.iterator().sure()
|
||||
val iterator = this.iterator()!!
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -225,7 +225,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().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -172,7 +172,7 @@ public inline fun LongArray.foldRight(initial: Long, operation: (Long, Long) ->
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun LongArray.reduce(operation: (Long, Long) -> Long): Long {
|
||||
val iterator = this.iterator().sure()
|
||||
val iterator = this.iterator()!!
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +226,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().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -172,7 +172,7 @@ public inline fun ShortArray.foldRight(initial: Short, operation: (Short, Short)
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun ShortArray.reduce(operation: (Short, Short) -> Short): Short {
|
||||
val iterator = this.iterator().sure()
|
||||
val iterator = this.iterator()!!
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -226,7 +226,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().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
|
||||
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
|
||||
|
||||
@@ -75,26 +75,26 @@ 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).sure()
|
||||
public inline fun ByteArray.copyOf(newLength: Int = this.size) : ByteArray = Arrays.copyOf(this, newLength).sure()
|
||||
public inline fun ShortArray.copyOf(newLength: Int = this.size) : ShortArray = Arrays.copyOf(this, newLength).sure()
|
||||
public inline fun IntArray.copyOf(newLength: Int = this.size) : IntArray = Arrays.copyOf(this, newLength).sure()
|
||||
public inline fun LongArray.copyOf(newLength: Int = this.size) : LongArray = Arrays.copyOf(this, newLength).sure()
|
||||
public inline fun FloatArray.copyOf(newLength: Int = this.size) : FloatArray = Arrays.copyOf(this, newLength).sure()
|
||||
public inline fun DoubleArray.copyOf(newLength: Int = this.size) : DoubleArray = Arrays.copyOf(this, newLength).sure()
|
||||
public inline fun CharArray.copyOf(newLength: Int = this.size) : CharArray = Arrays.copyOf(this, newLength).sure()
|
||||
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 BooleanArray.copyOfRange(from: Int, to: Int) : BooleanArray = Arrays.copyOfRange(this, from, to).sure()
|
||||
public inline fun ByteArray.copyOfRange(from: Int, to: Int) : ByteArray = Arrays.copyOfRange(this, from, to).sure()
|
||||
public inline fun ShortArray.copyOfRange(from: Int, to: Int) : ShortArray = Arrays.copyOfRange(this, from, to).sure()
|
||||
public inline fun IntArray.copyOfRange(from: Int, to: Int) : IntArray = Arrays.copyOfRange(this, from, to).sure()
|
||||
public inline fun LongArray.copyOfRange(from: Int, to: Int) : LongArray = Arrays.copyOfRange(this, from, to).sure()
|
||||
public inline fun FloatArray.copyOfRange(from: Int, to: Int) : FloatArray = Arrays.copyOfRange(this, from, to).sure()
|
||||
public inline fun DoubleArray.copyOfRange(from: Int, to: Int) : DoubleArray = Arrays.copyOfRange(this, from, to).sure()
|
||||
public inline fun CharArray.copyOfRange(from: Int, to: Int) : CharArray = Arrays.copyOfRange(this, from, to).sure()
|
||||
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>
|
||||
|
||||
@@ -163,7 +163,7 @@ public inline fun <T> Iterable<T>.foldRight(initial: T, operation: (T, T) -> T):
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt reduce
|
||||
*/
|
||||
public inline fun <T> Iterable<T>.reduce(operation: (T, T) -> T): T {
|
||||
val iterator = this.iterator().sure()
|
||||
val iterator = this.iterator()!!
|
||||
if (!iterator.hasNext()) {
|
||||
throw UnsupportedOperationException("Empty iterable can't be reduced")
|
||||
}
|
||||
@@ -217,7 +217,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().sure()
|
||||
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().sure().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().sure()
|
||||
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().sure()
|
||||
get() = getKey()!!
|
||||
|
||||
/** Returns the value of the entry */
|
||||
val <K,V> Map.Entry<K,V>.value : V
|
||||
get() = getValue().sure()
|
||||
get() = getValue()!!
|
||||
|
||||
/** Returns the key of the entry */
|
||||
fun <K,V> Map.Entry<K,V>.component1() : K {
|
||||
return getKey().sure()
|
||||
return getKey()!!
|
||||
}
|
||||
|
||||
/** Returns the value of the entry */
|
||||
fun <K,V> Map.Entry<K,V>.component2() : V {
|
||||
return getValue().sure()
|
||||
return getValue()!!
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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().sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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().sure()
|
||||
public inline fun String.trim() : String = (this as java.lang.String).trim()!!
|
||||
|
||||
public inline fun String.toUpperCase() : String = (this as java.lang.String).toUpperCase().sure()
|
||||
public inline fun String.toUpperCase() : String = (this as java.lang.String).toUpperCase()!!
|
||||
|
||||
public inline fun String.toLowerCase() : String = (this as java.lang.String).toLowerCase().sure()
|
||||
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().sure()
|
||||
public inline fun String.getBytes() : ByteArray = (this as java.lang.String).getBytes()!!
|
||||
|
||||
public inline fun String.toCharArray() : CharArray = (this as java.lang.String).toCharArray().sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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()).sure()
|
||||
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).sure()
|
||||
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().sure()
|
||||
public inline fun String.intern() : String = (this as java.lang.String).intern()!!
|
||||
|
||||
public inline fun String.isEmpty() : Boolean = (this as java.lang.String).isEmpty().sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
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().sure()
|
||||
return (this as java.lang.String).getBytes()!!
|
||||
} else {
|
||||
return (this as java.lang.String).getBytes(encoding).sure()
|
||||
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).sure()
|
||||
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).sure()
|
||||
public inline fun String.toShort() : Short = java.lang.Short.parseShort(this).sure()
|
||||
public inline fun String.toInt() : Int = java.lang.Integer.parseInt(this).sure()
|
||||
public inline fun String.toLong() : Long = java.lang.Long.parseLong(this).sure()
|
||||
public inline fun String.toFloat() : Float = java.lang.Float.parseFloat(this).sure()
|
||||
public inline fun String.toDouble() : Double = java.lang.Double.parseDouble(this).sure()
|
||||
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).sure()
|
||||
return java.util.regex.Pattern.compile(this, flags)!!
|
||||
}
|
||||
|
||||
inline val String.reader : StringReader
|
||||
|
||||
@@ -24,7 +24,7 @@ Executes given calculation under read lock
|
||||
Returns result of the calculation
|
||||
*/
|
||||
public inline fun <T> ReentrantReadWriteLock.read(action: ()->T) : T {
|
||||
val rl = readLock().sure()
|
||||
val rl = readLock()!!
|
||||
rl.lock()
|
||||
try {
|
||||
return action()
|
||||
@@ -41,12 +41,12 @@ If such write has been initiated by checking some condition, the condition must
|
||||
Returns result of the calculation
|
||||
*/
|
||||
public inline fun <T> ReentrantReadWriteLock.write(action: ()->T) : T {
|
||||
val rl = readLock().sure()
|
||||
val rl = readLock()!!
|
||||
|
||||
val readCount = if (getWriteHoldCount() == 0) getReadHoldCount() else 0
|
||||
readCount times { rl.unlock() }
|
||||
|
||||
val wl = writeLock().sure()
|
||||
val wl = writeLock()!!
|
||||
wl.lock()
|
||||
try {
|
||||
return action()
|
||||
|
||||
@@ -6,10 +6,10 @@ import java.util.concurrent.Future
|
||||
import java.util.concurrent.Callable
|
||||
|
||||
inline val currentThread : Thread
|
||||
get() = Thread.currentThread().sure()
|
||||
get() = Thread.currentThread()!!
|
||||
|
||||
inline var Thread.name : String
|
||||
get() = getName().sure()
|
||||
get() = getName()!!
|
||||
set(name: String) { setName(name) }
|
||||
|
||||
inline var Thread.daemon : Boolean
|
||||
@@ -66,7 +66,7 @@ public inline fun Executor.invoke(action: ()->Unit) {
|
||||
*/
|
||||
public inline fun <T>ExecutorService.submit(action: ()->T):Future<T> {
|
||||
val c:Callable<T> = callable(action)
|
||||
return submit(c).sure();
|
||||
return submit(c)!!;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,7 @@ var Element.childrenText: String
|
||||
i++
|
||||
}
|
||||
}
|
||||
return buffer.toString().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
set(value) {
|
||||
val element = this as Element
|
||||
@@ -336,7 +336,7 @@ public fun nodesToXmlString(nodes: Iterable<Node>, xmlDeclaration: Boolean = fal
|
||||
for (n in nodes) {
|
||||
builder.append(n.toXmlString(xmlDeclaration))
|
||||
}
|
||||
return builder.toString().sure()
|
||||
return builder.toString()!!
|
||||
}
|
||||
|
||||
// Syntax sugar
|
||||
@@ -359,7 +359,7 @@ inline fun Element.plusAssign(text: String?): Element = this.addText(text)
|
||||
* Creates a new element which can be configured via a function
|
||||
*/
|
||||
fun Document.createElement(name: String, init: Element.()-> Unit): Element {
|
||||
val elem = this.createElement(name).sure()
|
||||
val elem = this.createElement(name)!!
|
||||
elem.init()
|
||||
return elem
|
||||
}
|
||||
@@ -368,7 +368,7 @@ fun Document.createElement(name: String, init: Element.()-> Unit): Element {
|
||||
* Creates a new element to an element which has an owner Document which can be configured via a function
|
||||
*/
|
||||
fun Element.createElement(name: String, doc: Document? = null, init: Element.()-> Unit): Element {
|
||||
val elem = ownerDocument(doc).createElement(name).sure()
|
||||
val elem = ownerDocument(doc).createElement(name)!!
|
||||
elem.init()
|
||||
return elem
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ fun Element.removeClass(cssClass: String): Boolean {
|
||||
|
||||
/** Creates a new document with the given document builder*/
|
||||
public fun createDocument(builder: DocumentBuilder): Document {
|
||||
return builder.newDocument().sure()
|
||||
return builder.newDocument()!!
|
||||
}
|
||||
|
||||
/** Creates a new document with an optional DocumentBuilderFactory */
|
||||
@@ -209,13 +209,13 @@ public fun parseXml(inputSource: InputSource, builder: DocumentBuilder = default
|
||||
|
||||
|
||||
/** Creates a new TrAX transformer */
|
||||
public fun createTransformer(source: Source? = null, factory: TransformerFactory = TransformerFactory.newInstance().sure()): Transformer {
|
||||
public fun createTransformer(source: Source? = null, factory: TransformerFactory = TransformerFactory.newInstance()!!): Transformer {
|
||||
val transformer = if (source != null) {
|
||||
factory.newTransformer(source)
|
||||
} else {
|
||||
factory.newTransformer()
|
||||
}
|
||||
return transformer.sure()
|
||||
return transformer!!
|
||||
}
|
||||
|
||||
/** Converts the node to an XML String */
|
||||
@@ -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().sure()
|
||||
return writer.toString()!!
|
||||
}
|
||||
|
||||
/** Converts the node to an XML String and writes it to the given [[Writer]] */
|
||||
|
||||
@@ -25,7 +25,7 @@ public fun File.recurse(block: (File) -> Unit): Unit {
|
||||
* Returns this if the file is a directory or the parent if its a file inside a directory
|
||||
*/
|
||||
inline val File.directory: File
|
||||
get() = if (this.isDirectory()) this else this.getParentFile().sure()
|
||||
get() = if (this.isDirectory()) this else this.getParentFile()!!
|
||||
|
||||
/**
|
||||
* Returns the canoncial path of the file
|
||||
|
||||
@@ -13,7 +13,7 @@ public val defaultBufferSize: Int = 64 * 1024
|
||||
/**
|
||||
* Returns the default [[Charset]] which defaults to UTF-8
|
||||
*/
|
||||
public val defaultCharset: Charset = Charset.forName("UTF-8").sure()
|
||||
public val defaultCharset: Charset = Charset.forName("UTF-8")!!
|
||||
|
||||
|
||||
/** Prints the given message to [[System.out]] */
|
||||
@@ -251,7 +251,7 @@ class LineIterator(val reader: BufferedReader) : Iterator<String> {
|
||||
}
|
||||
val answer = nextValue
|
||||
nextValue = null
|
||||
return answer.sure()
|
||||
return answer!!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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().sure()
|
||||
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().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -333,5 +333,5 @@ public fun URL.readText(encoding: Charset): String = readBytes().toString(encodi
|
||||
*
|
||||
* This method is not recommended on huge files.
|
||||
*/
|
||||
public fun URL.readBytes(): ByteArray = this.openStream().sure().use<InputStream,ByteArray>{ it.readBytes() }
|
||||
public fun URL.readBytes(): ByteArray = this.openStream()!!.use<InputStream,ByteArray>{ it.readBytes() }
|
||||
|
||||
|
||||
@@ -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).sure()
|
||||
public fun BigInteger.plus(other: BigInteger) : BigInteger = this.add(other)!!
|
||||
|
||||
public fun BigInteger.minus(other: BigInteger) : BigInteger = this.subtract(other).sure()
|
||||
public fun BigInteger.minus(other: BigInteger) : BigInteger = this.subtract(other)!!
|
||||
|
||||
public fun BigInteger.times(other: BigInteger) : BigInteger = this.multiply(other).sure()
|
||||
public fun BigInteger.times(other: BigInteger) : BigInteger = this.multiply(other)!!
|
||||
|
||||
public fun BigInteger.div(other: BigInteger) : BigInteger = this.divide(other).sure()
|
||||
public fun BigInteger.div(other: BigInteger) : BigInteger = this.divide(other)!!
|
||||
|
||||
public fun BigInteger.minus() : BigInteger = this.negate().sure()
|
||||
public fun BigInteger.minus() : BigInteger = this.negate()!!
|
||||
|
||||
|
||||
public fun BigDecimal.plus(other: BigDecimal) : BigDecimal = this.add(other).sure()
|
||||
public fun BigDecimal.plus(other: BigDecimal) : BigDecimal = this.add(other)!!
|
||||
|
||||
public fun BigDecimal.minus(other: BigDecimal) : BigDecimal = this.subtract(other).sure()
|
||||
public fun BigDecimal.minus(other: BigDecimal) : BigDecimal = this.subtract(other)!!
|
||||
|
||||
public fun BigDecimal.times(other: BigDecimal) : BigDecimal = this.multiply(other).sure()
|
||||
public fun BigDecimal.times(other: BigDecimal) : BigDecimal = this.multiply(other)!!
|
||||
|
||||
public fun BigDecimal.div(other: BigDecimal) : BigDecimal = this.divide(other).sure()
|
||||
public fun BigDecimal.div(other: BigDecimal) : BigDecimal = this.divide(other)!!
|
||||
|
||||
public fun BigDecimal.mod(other: BigDecimal) : BigDecimal = this.remainder(other).sure()
|
||||
public fun BigDecimal.mod(other: BigDecimal) : BigDecimal = this.remainder(other)!!
|
||||
|
||||
public fun BigDecimal.minus() : BigDecimal = this.negate().sure()
|
||||
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.sure().get()?.add(builder)
|
||||
AllModules.modules!!.get()?.add(builder)
|
||||
}
|
||||
|
||||
class SourcesBuilder(val parent: ModuleBuilder) {
|
||||
|
||||
@@ -129,7 +129,7 @@ public inline fun <T> T?.makeString(separator: String = ", ", prefix: String = "
|
||||
buffer.append(this)
|
||||
}
|
||||
buffer.append(postfix)
|
||||
return buffer.toString().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class ChangeSupport {
|
||||
var listeners = nameListeners?.get(name)
|
||||
if (listeners == null) {
|
||||
listeners = arrayList<ChangeListener>()
|
||||
nameListeners?.put(name, listeners.sure())
|
||||
nameListeners?.put(name, listeners!!)
|
||||
}
|
||||
listeners?.add(listener)
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ public abstract class AbstractIterator<T>: Iterator<T> {
|
||||
override fun next(): T {
|
||||
if (!hasNext()) throw NoSuchElementException()
|
||||
state = State.NotReady
|
||||
return next.sure()
|
||||
return next!!
|
||||
}
|
||||
|
||||
/** Returns the next element in the iteration without advancing the iteration */
|
||||
fun peek(): T {
|
||||
if (!hasNext()) throw NoSuchElementException()
|
||||
return next.sure();
|
||||
return next!!;
|
||||
}
|
||||
|
||||
private fun tryToComputeNext(): Boolean {
|
||||
|
||||
@@ -116,7 +116,7 @@ public open class ToStringFormatter : Formatter {
|
||||
}
|
||||
}
|
||||
|
||||
public val defaultLocale : Locale = Locale.getDefault().sure()
|
||||
public val defaultLocale : Locale = Locale.getDefault()!!
|
||||
|
||||
/**
|
||||
* Formats values using a given [[Locale]] for internationalisation
|
||||
@@ -125,9 +125,9 @@ public open class LocaleFormatter(val locale : Locale = defaultLocale) : ToStrin
|
||||
|
||||
public override fun toString() : String = "LocaleFormatter{$locale}"
|
||||
|
||||
public var numberFormat : NumberFormat = NumberFormat.getInstance(locale).sure()
|
||||
public var numberFormat : NumberFormat = NumberFormat.getInstance(locale)!!
|
||||
|
||||
public var dateFormat : DateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, locale).sure()
|
||||
public var dateFormat : DateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, locale)!!
|
||||
|
||||
public override fun format(out : Appendable, value : Any?) {
|
||||
if (value is Number) {
|
||||
|
||||
@@ -28,7 +28,7 @@ public var asserter: Asserter
|
||||
}
|
||||
//debug("using asserter $_asserter")
|
||||
}
|
||||
return _asserter.sure()
|
||||
return _asserter!!
|
||||
}
|
||||
|
||||
set(value) {
|
||||
|
||||
@@ -105,7 +105,7 @@ class CollectionTest {
|
||||
assertNull(x)
|
||||
|
||||
val f = data.find{it.startsWith("f")}
|
||||
f.sure()
|
||||
f!!
|
||||
assertEquals("foo", f)
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ class CollectionTest {
|
||||
private val collection = collection
|
||||
|
||||
override fun iterator(): Iterator<T> {
|
||||
return collection.iterator().sure()
|
||||
return collection.iterator()!!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class TestBuilt<T>(name: String, val builder: TestBuilder<T>, val test: TestBuil
|
||||
private var myState: T? = null
|
||||
|
||||
var state : T
|
||||
get() = myState.sure()
|
||||
get() = myState!!
|
||||
set(newState: T) { myState = newState }
|
||||
|
||||
override fun countTestCases(): Int = 1
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.concurrent.TimeUnit.*
|
||||
class ThreadTest {
|
||||
test fun scheduledTask() {
|
||||
|
||||
val pool = Executors.newFixedThreadPool(1).sure()
|
||||
val pool = Executors.newFixedThreadPool(1)!!
|
||||
val countDown = CountDownLatch(1)
|
||||
pool {
|
||||
countDown.countDown()
|
||||
@@ -21,7 +21,7 @@ class ThreadTest {
|
||||
|
||||
test fun callableInvoke() {
|
||||
|
||||
val pool = Executors.newFixedThreadPool(1).sure()
|
||||
val pool = Executors.newFixedThreadPool(1)!!
|
||||
val future = pool<String> {
|
||||
"Hello"
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class IteratorsJVMTest {
|
||||
|
||||
test fun flatMapAndTakeExtractTheTransformedElements() {
|
||||
fun intToBinaryDigits() = { (i: Int) ->
|
||||
val binary = Integer.toBinaryString(i).sure()
|
||||
val binary = Integer.toBinaryString(i)!!
|
||||
var index = 0
|
||||
iterate<Char> { if (index < binary.length()) binary.get(index++) else null }
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ fun parseAtomic(tokens : Deque<Token>) : ParseResult<Expression> {
|
||||
else
|
||||
Failure("Expecting ')'")
|
||||
}
|
||||
is Number -> Success(Num(Integer.parseInt((token as Token).text).sure()))
|
||||
is Number -> Success(Num(Integer.parseInt((token as Token).text)!!))
|
||||
else -> Failure("Unexpected EOF")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ class LocaleTemplateTest : TestCase() {
|
||||
}
|
||||
|
||||
fun testFrance() : Unit {
|
||||
format(LocaleFormatter(Locale.FRANCE.sure()))
|
||||
format(LocaleFormatter(Locale.FRANCE!!))
|
||||
}
|
||||
|
||||
fun testGermany() : Unit {
|
||||
format(LocaleFormatter(Locale.GERMANY.sure()))
|
||||
format(LocaleFormatter(Locale.GERMANY!!))
|
||||
}
|
||||
|
||||
fun format(formatter: LocaleFormatter): Unit {
|
||||
|
||||
@@ -137,14 +137,14 @@ fun inheritedExtensionProperties(properties: Collection<KProperty>): Map<KClass,
|
||||
// TODO for some reason the SortedMap causes kotlin to freak out a little :)
|
||||
fun extensionFunctions(functions: Collection<KFunction>): Map<KClass, List<KFunction>> {
|
||||
val map = TreeMap<KClass, List<KFunction>>()
|
||||
functions.filter{ it.extensionClass != null }.groupByTo(map){ it.extensionClass.sure() }
|
||||
functions.filter{ it.extensionClass != null }.groupByTo(map){ it.extensionClass!! }
|
||||
return map
|
||||
}
|
||||
|
||||
// TODO for some reason the SortedMap causes kotlin to freak out a little :)
|
||||
fun extensionProperties(properties: Collection<KProperty>): Map<KClass, List<KProperty>> {
|
||||
val map = TreeMap<KClass, List<KProperty>>()
|
||||
properties.filter{ it.extensionClass != null }.groupByTo(map){ it.extensionClass.sure() }
|
||||
properties.filter{ it.extensionClass != null }.groupByTo(map){ it.extensionClass!! }
|
||||
return map
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ class KModel(val context: BindingContext, val config: KDocConfig, val sourceDirs
|
||||
public val packageMap: SortedMap<String, KPackage> = TreeMap<String, KPackage>()
|
||||
|
||||
public val allPackages: Collection<KPackage>
|
||||
get() = packageMap.values().sure()
|
||||
get() = packageMap.values()!!
|
||||
|
||||
/** Returns the local packages */
|
||||
public val packages: Collection<KPackage>
|
||||
@@ -345,7 +345,7 @@ class KModel(val context: BindingContext, val config: KDocConfig, val sourceDirs
|
||||
}
|
||||
|
||||
fun wikiConvert(text: String, linkRenderer: LinkRenderer, fileName: String?): String {
|
||||
return markdownProcessor.markdownToHtml(text, linkRenderer).sure()
|
||||
return markdownProcessor.markdownToHtml(text, linkRenderer)!!
|
||||
}
|
||||
|
||||
fun sourceLinkFor(filePath: String, sourceLine: Int, lineLinkText: String = "#L"): String? {
|
||||
@@ -552,8 +552,8 @@ class KModel(val context: BindingContext, val config: KDocConfig, val sourceDirs
|
||||
// source code function if folks adopted a convention of naming the test method after the
|
||||
// method its acting as a demo/test for
|
||||
if (words.size > 1) {
|
||||
val includeFile = words[0].sure()
|
||||
val fnName = words[1].sure()
|
||||
val includeFile = words[0]!!
|
||||
val fnName = words[1]!!
|
||||
val content = findFunctionInclude(psiElement, includeFile, fnName)
|
||||
if (content != null) {
|
||||
return content
|
||||
@@ -571,7 +571,7 @@ class KModel(val context: BindingContext, val config: KDocConfig, val sourceDirs
|
||||
protected fun findFunctionInclude(psiElement: PsiElement, includeFile: String, functionName: String): String? {
|
||||
var dir = psiElement.getContainingFile()?.getParent()
|
||||
if (dir != null) {
|
||||
val file = relativeFile(dir.sure(), includeFile)
|
||||
val file = relativeFile(dir!!, includeFile)
|
||||
if (file != null) {
|
||||
val text = file.getText()
|
||||
if (text != null) {
|
||||
@@ -947,7 +947,7 @@ class KPackage(model: KModel, val descriptor: NamespaceDescriptor,
|
||||
public val classMap: SortedMap<String, KClass> = TreeMap<String, KClass>()
|
||||
|
||||
public val classes: Collection<KClass>
|
||||
get() = classMap.values().sure().filter{ it.isApi() }
|
||||
get() = classMap.values()!!.filter{ it.isApi() }
|
||||
|
||||
public val annotations: Collection<KClass> = ArrayList<KClass>()
|
||||
|
||||
@@ -1046,7 +1046,7 @@ class KPackage(model: KModel, val descriptor: NamespaceDescriptor,
|
||||
}
|
||||
|
||||
class KType(val jetType: JetType, model: KModel, val klass: KClass?, val arguments: MutableList<KType> = ArrayList<KType>())
|
||||
: KNamed(klass?.name ?: jetType.toString().sure(), model, jetType.getConstructor().getDeclarationDescriptor().sure()) {
|
||||
: KNamed(klass?.name ?: jetType.toString()!!, model, jetType.getConstructor().getDeclarationDescriptor()!!) {
|
||||
{
|
||||
if (klass != null) {
|
||||
this.wikiDescription = klass.wikiDescription
|
||||
|
||||
Vendored
+1
-1
@@ -257,7 +257,7 @@ abstract class PackageTemplateSupport(open val pkg: KPackage) : KDocTemplate() {
|
||||
}
|
||||
val pType = if (p.isVarArg()) {
|
||||
print("vararg ")
|
||||
p.varArgType().sure()
|
||||
p.varArgType()!!
|
||||
} else {
|
||||
p.aType
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ abstract class TextTemplate() : TemplateSupport(), Printer {
|
||||
fun renderToText(): String {
|
||||
val buffer = StringWriter()
|
||||
renderTo(buffer)
|
||||
return buffer.toString().sure()
|
||||
return buffer.toString()!!
|
||||
}
|
||||
|
||||
fun renderTo(writer: Writer): Unit {
|
||||
|
||||
@@ -19,7 +19,7 @@ class PegdownTest() : TestCase() {
|
||||
"a [Link](somewhere) blah")
|
||||
|
||||
for (text in markups) {
|
||||
val answer = markdownProcessor.markdownToHtml(text, linkRenderer).sure()
|
||||
val answer = markdownProcessor.markdownToHtml(text, linkRenderer)!!
|
||||
println("$text = $answer")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user