Split API to separate overloads with radix parameter and without.
Remove unused radix parameter from toFloat and toDouble. Update public API dump. #KT-8286, #KT-7930
This commit is contained in:
@@ -17,42 +17,71 @@ public inline fun String.toBoolean(): Boolean = java.lang.Boolean.parseBoolean(t
|
||||
* @throws NumberFormatException if the string is not a valid representation of a number.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.toByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(this, radix)
|
||||
public inline fun String.toByte(): Byte = java.lang.Byte.parseByte(this)
|
||||
|
||||
/**
|
||||
* Parses the string as a signed [Byte] number and returns the result.
|
||||
* @throws NumberFormatException if the string is not a valid representation of a number.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.toByte(radix: Int): Byte = java.lang.Byte.parseByte(this, radix)
|
||||
|
||||
|
||||
/**
|
||||
* Parses the string as a [Short] number and returns the result.
|
||||
* @throws NumberFormatException if the string is not a valid representation of a number.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.toShort(radix: Int = 10): Short = java.lang.Short.parseShort(this, radix)
|
||||
public inline fun String.toShort(): Short = java.lang.Short.parseShort(this)
|
||||
|
||||
/**
|
||||
* Parses the string as a [Short] number and returns the result.
|
||||
* @throws NumberFormatException if the string is not a valid representation of a number.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.toShort(radix: Int): Short = java.lang.Short.parseShort(this, radix)
|
||||
|
||||
/**
|
||||
* Parses the string as an [Int] number and returns the result.
|
||||
* @throws NumberFormatException if the string is not a valid representation of a number.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.toInt(radix: Int = 10): Int = java.lang.Integer.parseInt(this, radix)
|
||||
public inline fun String.toInt(): Int = java.lang.Integer.parseInt(this)
|
||||
|
||||
/**
|
||||
* Parses the string as an [Int] number and returns the result.
|
||||
* @throws NumberFormatException if the string is not a valid representation of a number.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.toInt(radix: Int): Int = java.lang.Integer.parseInt(this, radix)
|
||||
|
||||
/**
|
||||
* Parses the string as a [Long] number and returns the result.
|
||||
* @throws NumberFormatException if the string is not a valid representation of a number.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.toLong(radix: Int = 10): Long = java.lang.Long.parseLong(this, radix)
|
||||
public inline fun String.toLong(): Long = java.lang.Long.parseLong(this)
|
||||
|
||||
/**
|
||||
* Parses the string as a [Long] number and returns the result.
|
||||
* @throws NumberFormatException if the string is not a valid representation of a number.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.toLong(radix: Int): Long = java.lang.Long.parseLong(this, radix)
|
||||
|
||||
/**
|
||||
* Parses the string as a [Float] number and returns the result.
|
||||
* @throws NumberFormatException if the string is not a valid representation of a number.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.toFloat(radix: Int = 10): Float = java.lang.Float.parseFloat(this)
|
||||
public inline fun String.toFloat(): Float = java.lang.Float.parseFloat(this)
|
||||
|
||||
/**
|
||||
* Parses the string as a [Double] number and returns the result.
|
||||
* @throws NumberFormatException if the string is not a valid representation of a number.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.toDouble(radix: Int = 10): Double = java.lang.Double.parseDouble(this)
|
||||
public inline fun String.toDouble(): Double = java.lang.Double.parseDouble(this)
|
||||
|
||||
|
||||
|
||||
@@ -60,7 +89,13 @@ public inline fun String.toDouble(radix: Int = 10): Double = java.lang.Double.pa
|
||||
* Parses the string as a signed [Byte] number and returns the result
|
||||
* or `null` if the string is not a valid representation of a number.
|
||||
*/
|
||||
public fun String.toByteOrNull(radix: Int = 10): Byte? {
|
||||
public fun String.toByteOrNull(): Byte? = toByteOrNull(radix = 10)
|
||||
|
||||
/**
|
||||
* Parses the string as a signed [Byte] number and returns the result
|
||||
* or `null` if the string is not a valid representation of a number.
|
||||
*/
|
||||
public fun String.toByteOrNull(radix: Int): Byte? {
|
||||
val int = this.toIntOrNull(radix) ?: return null
|
||||
if (int < Byte.MIN_VALUE || int > Byte.MAX_VALUE) return null
|
||||
return int.toByte()
|
||||
@@ -70,7 +105,13 @@ public fun String.toByteOrNull(radix: Int = 10): Byte? {
|
||||
* Parses the string as a [Short] number and returns the result
|
||||
* or `null` if the string is not a valid representation of a number.
|
||||
*/
|
||||
public fun String.toShortOrNull(radix: Int = 10): Short? {
|
||||
public fun String.toShortOrNull(): Short? = toShortOrNull(radix = 10)
|
||||
|
||||
/**
|
||||
* Parses the string as a [Short] number and returns the result
|
||||
* or `null` if the string is not a valid representation of a number.
|
||||
*/
|
||||
public fun String.toShortOrNull(radix: Int): Short? {
|
||||
val int = this.toIntOrNull(radix) ?: return null
|
||||
if (int < Short.MIN_VALUE || int > Short.MAX_VALUE) return null
|
||||
return int.toShort()
|
||||
@@ -80,7 +121,13 @@ public fun String.toShortOrNull(radix: Int = 10): Short? {
|
||||
* Parses the string as an [Int] number and returns the result
|
||||
* or `null` if the string is not a valid representation of a number.
|
||||
*/
|
||||
public fun String.toIntOrNull(radix: Int = 10): Int? {
|
||||
public fun String.toIntOrNull(): Int? = toIntOrNull(radix = 10)
|
||||
|
||||
/**
|
||||
* Parses the string as an [Int] number and returns the result
|
||||
* or `null` if the string is not a valid representation of a number.
|
||||
*/
|
||||
public fun String.toIntOrNull(radix: Int): Int? {
|
||||
if (radix < Character.MIN_RADIX) throw NumberFormatException("radix $radix less than Character.MIN_RADIX")
|
||||
if (radix > Character.MAX_RADIX) throw NumberFormatException("radix $radix greater than Character.MAX_RADIX")
|
||||
|
||||
@@ -134,7 +181,13 @@ public fun String.toIntOrNull(radix: Int = 10): Int? {
|
||||
* Parses the string as a [Long] number and returns the result
|
||||
* or `null` if the string is not a valid representation of a number.
|
||||
*/
|
||||
public fun String.toLongOrNull(radix: Int = 10): Long? {
|
||||
public fun String.toLongOrNull(): Long? = toLongOrNull(radix = 10)
|
||||
|
||||
/**
|
||||
* Parses the string as a [Long] number and returns the result
|
||||
* or `null` if the string is not a valid representation of a number.
|
||||
*/
|
||||
public fun String.toLongOrNull(radix: Int): Long? {
|
||||
if (radix < Character.MIN_RADIX) throw NumberFormatException("radix $radix less than Character.MIN_RADIX")
|
||||
if (radix > Character.MAX_RADIX) throw NumberFormatException("radix $radix greater than Character.MAX_RADIX")
|
||||
|
||||
|
||||
@@ -2522,11 +2522,21 @@ public final class kotlin/text/StringsKt {
|
||||
public static final fun takeLastWhile (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ljava/lang/String;
|
||||
public static final fun takeWhile (Ljava/lang/CharSequence;Lkotlin/jvm/functions/Function1;)Ljava/lang/CharSequence;
|
||||
public static final fun takeWhile (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ljava/lang/String;
|
||||
public static final fun toByteOrNull (Ljava/lang/String;)Ljava/lang/Byte;
|
||||
public static final fun toByteOrNull (Ljava/lang/String;I)Ljava/lang/Byte;
|
||||
public static final fun toCollection (Ljava/lang/CharSequence;Ljava/util/Collection;)Ljava/util/Collection;
|
||||
public static final fun toDoubleOrNull (Ljava/lang/String;)Ljava/lang/Double;
|
||||
public static final fun toFloatOrNull (Ljava/lang/String;)Ljava/lang/Float;
|
||||
public static final fun toHashSet (Ljava/lang/CharSequence;)Ljava/util/HashSet;
|
||||
public static final fun toIntOrNull (Ljava/lang/String;)Ljava/lang/Integer;
|
||||
public static final fun toIntOrNull (Ljava/lang/String;I)Ljava/lang/Integer;
|
||||
public static final fun toList (Ljava/lang/CharSequence;)Ljava/util/List;
|
||||
public static final fun toLongOrNull (Ljava/lang/String;)Ljava/lang/Long;
|
||||
public static final fun toLongOrNull (Ljava/lang/String;I)Ljava/lang/Long;
|
||||
public static final fun toMutableList (Ljava/lang/CharSequence;)Ljava/util/List;
|
||||
public static final fun toSet (Ljava/lang/CharSequence;)Ljava/util/Set;
|
||||
public static final fun toShortOrNull (Ljava/lang/String;)Ljava/lang/Short;
|
||||
public static final fun toShortOrNull (Ljava/lang/String;I)Ljava/lang/Short;
|
||||
public static final fun toSortedSet (Ljava/lang/CharSequence;)Ljava/util/SortedSet;
|
||||
public static final fun trim (Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
|
||||
public static final fun trim (Ljava/lang/CharSequence;Lkotlin/jvm/functions/Function1;)Ljava/lang/CharSequence;
|
||||
|
||||
Reference in New Issue
Block a user