Use Kotlin number extensions instead of java.lang.Integer/Long/Double/Float/Boolean
Recipe ID
org.openrewrite.kotlin.migrate.UseKotlinNumberApis$KtRecipeArtifact
io.moderne.recipe:recipes-kotlinReplaces JVM-only static helpers on boxed primitive types with their multiplatform Kotlin counterparts: parsing (s.toInt(), s.toLong(radix), s.toDouble(), s.toBoolean()), formatting (i.toString(2), l.toString(16)), bit operations (i.countOneBits(), l.rotateLeft(n)), constants (Int.MIN_VALUE), and compareTo.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.kotlin.migrate.UseKotlinNumberApis$KtRecipeIf the recipe isn’t available locally, install it with:
mod config recipes jar install io.moderne.recipe:recipes-kotlin:0.2.0Definition
This recipe runs the following recipes in order.
- Use
String.toInt()instead ofInteger.parseInt(s)org.openrewrite.kotlin.migrate.UseStringToInt$KtRecipe - Use
String.toInt(radix)instead ofInteger.parseInt(s, radix)org.openrewrite.kotlin.migrate.UseStringToIntWithRadix$KtRecipe - Use
Int.toString()instead ofInteger.toString(i)org.openrewrite.kotlin.migrate.UseIntToString$KtRecipe - Use
Int.toString(radix)instead ofInteger.toString(i, radix)org.openrewrite.kotlin.migrate.UseIntToStringWithRadix$KtRecipe - Use
Int.toString(2)instead ofInteger.toBinaryStringorg.openrewrite.kotlin.migrate.UseIntToStringBinary$KtRecipe - Use
Int.toString(16)instead ofInteger.toHexStringorg.openrewrite.kotlin.migrate.UseIntToStringHex$KtRecipe - Use
Int.toString(8)instead ofInteger.toOctalStringorg.openrewrite.kotlin.migrate.UseIntToStringOctal$KtRecipe - Use
Int.countOneBits()instead ofjava.lang.Integer.bitCountorg.openrewrite.kotlin.migrate.UseIntCountOneBits$KtRecipe - Use
Int.countLeadingZeroBits()instead ofInteger.numberOfLeadingZerosorg.openrewrite.kotlin.migrate.UseIntCountLeadingZeroBits$KtRecipe - Use
Int.countTrailingZeroBits()instead ofInteger.numberOfTrailingZerosorg.openrewrite.kotlin.migrate.UseIntCountTrailingZeroBits$KtRecipe - Use
Int.rotateLeft(n)instead ofInteger.rotateLeft(i, n)org.openrewrite.kotlin.migrate.UseIntRotateLeft$KtRecipe - Use
Int.rotateRight(n)instead ofInteger.rotateRight(i, n)org.openrewrite.kotlin.migrate.UseIntRotateRight$KtRecipe - Use
Int.MIN_VALUEinstead ofjava.lang.Integer.MIN_VALUEorg.openrewrite.kotlin.migrate.UseKotlinIntMin$KtRecipe - Use
Int.MAX_VALUEinstead ofjava.lang.Integer.MAX_VALUEorg.openrewrite.kotlin.migrate.UseKotlinIntMax$KtRecipe - Use
Int.compareToinstead ofjava.lang.Integer.compareorg.openrewrite.kotlin.migrate.UseIntCompareTo$KtRecipe - Use
String.toLong()instead ofjava.lang.Long.parseLong(s)org.openrewrite.kotlin.migrate.UseStringToLong$KtRecipe - Use
String.toLong(radix)instead ofLong.parseLong(s, radix)org.openrewrite.kotlin.migrate.UseStringToLongWithRadix$KtRecipe - Use
Long.toString()instead ofLong.toString(l)org.openrewrite.kotlin.migrate.UseLongToString$KtRecipe - Use
Long.toString(radix)instead ofLong.toString(l, radix)org.openrewrite.kotlin.migrate.UseLongToStringWithRadix$KtRecipe - Use
Long.countOneBits()instead ofjava.lang.Long.bitCountorg.openrewrite.kotlin.migrate.UseLongCountOneBits$KtRecipe - Use
Long.rotateLeft(n)instead ofLong.rotateLeft(l, n)org.openrewrite.kotlin.migrate.UseLongRotateLeft$KtRecipe - Use
Long.rotateRight(n)instead ofLong.rotateRight(l, n)org.openrewrite.kotlin.migrate.UseLongRotateRight$KtRecipe - Use
String.toDouble()instead ofjava.lang.Double.parseDouble(s)org.openrewrite.kotlin.migrate.UseStringToDouble$KtRecipe - Use
String.toFloat()instead ofjava.lang.Float.parseFloat(s)org.openrewrite.kotlin.migrate.UseStringToFloat$KtRecipe - Use
String.toBoolean()instead ofjava.lang.Boolean.parseBoolean(s)org.openrewrite.kotlin.migrate.UseStringToBoolean$KtRecipe
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats