Drop deprecations: preconditions with non-lazy message.

This commit is contained in:
Ilya Gorbunov
2016-01-16 18:36:51 +03:00
parent 768a23f7eb
commit 69f884dcd3
3 changed files with 1 additions and 69 deletions
@@ -16,20 +16,6 @@ public fun assert(value: Boolean) {
assert(value) { "Assertion failed" }
}
/**
* Throws an [AssertionError] with an optional [message] if the [value] is false
* and runtime assertions have been enabled on the JVM using the *-ea* JVM option.
*/
@Deprecated("Use assert with lazy message instead.", ReplaceWith("assert(value) { message }"), DeprecationLevel.ERROR)
public fun assert(value: Boolean, message: Any = "Assertion failed") {
@Suppress("DEPRECATION")
if (ASSERTIONS_ENABLED) {
if (!value) {
throw AssertionError(message)
}
}
}
/**
* Throws an [AssertionError] calculated by [lazyMessage] if the [value] is false
* and runtime assertions have been enabled on the JVM using the *-ea* JVM option.
@@ -11,18 +11,6 @@ import java.lang.IllegalStateException
*/
public fun require(value: Boolean): Unit = require(value) { "Failed requirement" }
/**
* Throws an [IllegalArgumentException] with an optional [message] if the [value] is false.
*
* @sample test.collections.PreconditionsTest.failingRequireWithMessage
*/
@Deprecated("Use require with lazy message instead.", ReplaceWith("require(value) { message }"), DeprecationLevel.ERROR)
public fun require(value: Boolean, message: Any = "Failed requirement"): Unit {
if (!value) {
throw IllegalArgumentException(message.toString())
}
}
/**
* Throws an [IllegalArgumentException] with the result of calling [lazyMessage] if the [value] is false.
*
@@ -40,21 +28,6 @@ public inline fun require(value: Boolean, lazyMessage: () -> Any): Unit {
*/
public fun <T:Any> requireNotNull(value: T?): T = requireNotNull(value) { "Required value was null" }
/**
* Throws an [IllegalArgumentException] with the given [message] if the [value] is null. Otherwise
* returns the not null value.
*
* @sample test.collections.PreconditionsTest.requireNotNull
*/
@Deprecated("Use requireNotNull with lazy message instead.", ReplaceWith("requireNotNull(value) { message }"), DeprecationLevel.ERROR)
public fun <T:Any> requireNotNull(value: T?, message: Any = "Required value was null"): T {
if (value == null) {
throw IllegalArgumentException(message.toString())
} else {
return value
}
}
/**
* Throws an [IllegalArgumentException] with the result of calling [lazyMessage] if the [value] is null. Otherwise
* returns the not null value.
@@ -75,18 +48,6 @@ public inline fun <T:Any> requireNotNull(value: T?, lazyMessage: () -> Any): T {
*/
public fun check(value: Boolean): Unit = check(value) { "Check failed" }
/**
* Throws an [IllegalStateException] with an optional [message] if the [value] is false.
*
* @sample test.collections.PreconditionsTest.failingCheckWithMessage
*/
@Deprecated("Use check with lazy message instead.", ReplaceWith("check(value) { message }"), DeprecationLevel.ERROR)
public fun check(value: Boolean, message: Any = "Check failed"): Unit {
if (!value) {
throw IllegalStateException(message.toString())
}
}
/**
* Throws an [IllegalStateException] with the result of calling [lazyMessage] if the [value] is false.
*
@@ -105,21 +66,6 @@ public inline fun check(value: Boolean, lazyMessage: () -> Any): Unit {
*/
public fun <T:Any> checkNotNull(value: T?): T = checkNotNull(value) { "Required value was null" }
/**
* Throws an [IllegalStateException] with the given [message] if the [value] is null. Otherwise
* returns the not null value.
*
* @sample test.collections.PreconditionsTest.checkNotNull
*/
@Deprecated("Use checkNotNull with lazy message instead.", ReplaceWith("checkNotNull(value) { message }"), DeprecationLevel.ERROR)
public fun <T:Any> checkNotNull(value: T?, message: Any = "Required value was null"): T {
if (value == null) {
throw IllegalStateException(message.toString())
} else {
return value
}
}
/**
* Throws an [IllegalStateException] with the result of calling [lazyMessage] if the [value] is null. Otherwise
* returns the not null value.