Use Kotlin array extensions instead of java.util.Arrays
Recipe ID
org.openrewrite.kotlin.migrate.UseKotlinArray$KtRecipeArtifact
io.moderne.recipe:recipes-kotlinReplaces JVM-only java.util.Arrays static helpers with the multiplatform Kotlin extensions on each primitive array (and Array<*>): contentToString(), contentEquals(), contentHashCode(), fill(), sort(), binarySearch(), copyOf(), the deep variants for nested arrays, and the String(charArray)/String(byteArray) constructors that become charArray.concatToString()/byteArray.decodeToString().
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.UseKotlinArray$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
IntArray.contentToString()instead ofArrays.toString(arr)org.openrewrite.kotlin.migrate.UseIntArrayContentToString$KtRecipe - Use
LongArray.contentToString()instead ofArrays.toString(arr)org.openrewrite.kotlin.migrate.UseLongArrayContentToString$KtRecipe - Use
ByteArray.contentToString()instead ofArrays.toString(arr)org.openrewrite.kotlin.migrate.UseByteArrayContentToString$KtRecipe - Use
ShortArray.contentToString()instead ofArrays.toString(arr)org.openrewrite.kotlin.migrate.UseShortArrayContentToString$KtRecipe - Use
CharArray.contentToString()instead ofArrays.toString(arr)org.openrewrite.kotlin.migrate.UseCharArrayContentToString$KtRecipe - Use
FloatArray.contentToString()instead ofArrays.toString(arr)org.openrewrite.kotlin.migrate.UseFloatArrayContentToString$KtRecipe - Use
DoubleArray.contentToString()instead ofArrays.toString(arr)org.openrewrite.kotlin.migrate.UseDoubleArrayContentToString$KtRecipe - Use
BooleanArray.contentToString()instead ofArrays.toString(arr)org.openrewrite.kotlin.migrate.UseBooleanArrayContentToString$KtRecipe - Use
Array.contentToString()instead ofArrays.toString(arr)org.openrewrite.kotlin.migrate.UseArrayContentToString$KtRecipe - Use
IntArray.contentEquals()instead ofArrays.equals(a, b)org.openrewrite.kotlin.migrate.UseIntArrayContentEquals$KtRecipe - Use
LongArray.contentEquals()instead ofArrays.equals(a, b)org.openrewrite.kotlin.migrate.UseLongArrayContentEquals$KtRecipe - Use
ByteArray.contentEquals()instead ofArrays.equals(a, b)org.openrewrite.kotlin.migrate.UseByteArrayContentEquals$KtRecipe - Use
ShortArray.contentEquals()instead ofArrays.equals(a, b)org.openrewrite.kotlin.migrate.UseShortArrayContentEquals$KtRecipe - Use
CharArray.contentEquals()instead ofArrays.equals(a, b)org.openrewrite.kotlin.migrate.UseCharArrayContentEquals$KtRecipe - Use
FloatArray.contentEquals()instead ofArrays.equals(a, b)org.openrewrite.kotlin.migrate.UseFloatArrayContentEquals$KtRecipe - Use
DoubleArray.contentEquals()instead ofArrays.equals(a, b)org.openrewrite.kotlin.migrate.UseDoubleArrayContentEquals$KtRecipe - Use
BooleanArray.contentEquals()instead ofArrays.equals(a, b)org.openrewrite.kotlin.migrate.UseBooleanArrayContentEquals$KtRecipe - Use
Array.contentEquals()instead ofArrays.equals(a, b)org.openrewrite.kotlin.migrate.UseArrayContentEquals$KtRecipe - Use
IntArray.contentHashCode()instead ofArrays.hashCode(arr)org.openrewrite.kotlin.migrate.UseIntArrayContentHashCode$KtRecipe - Use
LongArray.contentHashCode()instead ofArrays.hashCode(arr)org.openrewrite.kotlin.migrate.UseLongArrayContentHashCode$KtRecipe - Use
ByteArray.contentHashCode()instead ofArrays.hashCode(arr)org.openrewrite.kotlin.migrate.UseByteArrayContentHashCode$KtRecipe - Use
ShortArray.contentHashCode()instead ofArrays.hashCode(arr)org.openrewrite.kotlin.migrate.UseShortArrayContentHashCode$KtRecipe - Use
CharArray.contentHashCode()instead ofArrays.hashCode(arr)org.openrewrite.kotlin.migrate.UseCharArrayContentHashCode$KtRecipe - Use
FloatArray.contentHashCode()instead ofArrays.hashCode(arr)org.openrewrite.kotlin.migrate.UseFloatArrayContentHashCode$KtRecipe - Use
DoubleArray.contentHashCode()instead ofArrays.hashCode(arr)org.openrewrite.kotlin.migrate.UseDoubleArrayContentHashCode$KtRecipe - Use
BooleanArray.contentHashCode()instead ofArrays.hashCode(arr)org.openrewrite.kotlin.migrate.UseBooleanArrayContentHashCode$KtRecipe - Use
Array.contentHashCode()instead ofArrays.hashCode(arr)org.openrewrite.kotlin.migrate.UseArrayContentHashCode$KtRecipe - Use
Array.contentDeepToString()instead ofArrays.deepToString(arr)org.openrewrite.kotlin.migrate.UseArrayContentDeepToString$KtRecipe - Use
Array.contentDeepEquals()instead ofArrays.deepEquals(a, b)org.openrewrite.kotlin.migrate.UseArrayContentDeepEquals$KtRecipe - Use
Array.contentDeepHashCode()instead ofArrays.deepHashCode(arr)org.openrewrite.kotlin.migrate.UseArrayContentDeepHashCode$KtRecipe - Use
IntArray.fill()instead ofArrays.fill(arr, value)org.openrewrite.kotlin.migrate.UseIntArrayFill$KtRecipe - Use
LongArray.fill()instead ofArrays.fill(arr, value)org.openrewrite.kotlin.migrate.UseLongArrayFill$KtRecipe - Use
ByteArray.fill()instead ofArrays.fill(arr, value)org.openrewrite.kotlin.migrate.UseByteArrayFill$KtRecipe - Use
ShortArray.fill()instead ofArrays.fill(arr, value)org.openrewrite.kotlin.migrate.UseShortArrayFill$KtRecipe - Use
CharArray.fill()instead ofArrays.fill(arr, value)org.openrewrite.kotlin.migrate.UseCharArrayFill$KtRecipe - Use
FloatArray.fill()instead ofArrays.fill(arr, value)org.openrewrite.kotlin.migrate.UseFloatArrayFill$KtRecipe - Use
DoubleArray.fill()instead ofArrays.fill(arr, value)org.openrewrite.kotlin.migrate.UseDoubleArrayFill$KtRecipe - Use
BooleanArray.fill()instead ofArrays.fill(arr, value)org.openrewrite.kotlin.migrate.UseBooleanArrayFill$KtRecipe - Use
IntArray.sort()instead ofArrays.sort(arr)org.openrewrite.kotlin.migrate.UseIntArraySort$KtRecipe - Use
LongArray.sort()instead ofArrays.sort(arr)org.openrewrite.kotlin.migrate.UseLongArraySort$KtRecipe - Use
ByteArray.sort()instead ofArrays.sort(arr)org.openrewrite.kotlin.migrate.UseByteArraySort$KtRecipe - Use
ShortArray.sort()instead ofArrays.sort(arr)org.openrewrite.kotlin.migrate.UseShortArraySort$KtRecipe - Use
CharArray.sort()instead ofArrays.sort(arr)org.openrewrite.kotlin.migrate.UseCharArraySort$KtRecipe - Use
FloatArray.sort()instead ofArrays.sort(arr)org.openrewrite.kotlin.migrate.UseFloatArraySort$KtRecipe - Use
DoubleArray.sort()instead ofArrays.sort(arr)org.openrewrite.kotlin.migrate.UseDoubleArraySort$KtRecipe - Use
IntArray.binarySearch()instead ofArrays.binarySearch(arr, key)org.openrewrite.kotlin.migrate.UseIntArrayBinarySearch$KtRecipe - Use
LongArray.binarySearch()instead ofArrays.binarySearch(arr, key)org.openrewrite.kotlin.migrate.UseLongArrayBinarySearch$KtRecipe - Use
ByteArray.binarySearch()instead ofArrays.binarySearch(arr, key)org.openrewrite.kotlin.migrate.UseByteArrayBinarySearch$KtRecipe - Use
ShortArray.binarySearch()instead ofArrays.binarySearch(arr, key)org.openrewrite.kotlin.migrate.UseShortArrayBinarySearch$KtRecipe - Use
CharArray.binarySearch()instead ofArrays.binarySearch(arr, key)org.openrewrite.kotlin.migrate.UseCharArrayBinarySearch$KtRecipe - Use
FloatArray.binarySearch()instead ofArrays.binarySearch(arr, key)org.openrewrite.kotlin.migrate.UseFloatArrayBinarySearch$KtRecipe - Use
DoubleArray.binarySearch()instead ofArrays.binarySearch(arr, key)org.openrewrite.kotlin.migrate.UseDoubleArrayBinarySearch$KtRecipe - Use
IntArray.copyOf()instead ofArrays.copyOf(arr, newLength)org.openrewrite.kotlin.migrate.UseIntArrayCopyOf$KtRecipe - Use
LongArray.copyOf()instead ofArrays.copyOf(arr, newLength)org.openrewrite.kotlin.migrate.UseLongArrayCopyOf$KtRecipe - Use
ByteArray.copyOf()instead ofArrays.copyOf(arr, newLength)org.openrewrite.kotlin.migrate.UseByteArrayCopyOf$KtRecipe - Use
ShortArray.copyOf()instead ofArrays.copyOf(arr, newLength)org.openrewrite.kotlin.migrate.UseShortArrayCopyOf$KtRecipe - Use
CharArray.copyOf()instead ofArrays.copyOf(arr, newLength)org.openrewrite.kotlin.migrate.UseCharArrayCopyOf$KtRecipe - Use
FloatArray.copyOf()instead ofArrays.copyOf(arr, newLength)org.openrewrite.kotlin.migrate.UseFloatArrayCopyOf$KtRecipe - Use
DoubleArray.copyOf()instead ofArrays.copyOf(arr, newLength)org.openrewrite.kotlin.migrate.UseDoubleArrayCopyOf$KtRecipe - Use
BooleanArray.copyOf()instead ofArrays.copyOf(arr, newLength)org.openrewrite.kotlin.migrate.UseBooleanArrayCopyOf$KtRecipe - Use
CharArray.concatToString()instead ofString(charArray)org.openrewrite.kotlin.migrate.UseConcatToString$KtRecipe - Use
ByteArray.decodeToString()instead ofString(byteArray)org.openrewrite.kotlin.migrate.UseDecodeToString$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