Use Kotlin array extensions instead of java.util.Arrays

Proprietary

Replaces 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().

org.openrewrite.kotlin.migrate.UseKotlinArray$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.migrate.UseKotlinArray$KtRecipe'

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Use IntArray.contentToString() instead of Arrays.toString(arr)
  2. Use LongArray.contentToString() instead of Arrays.toString(arr)
  3. Use ByteArray.contentToString() instead of Arrays.toString(arr)
  4. Use ShortArray.contentToString() instead of Arrays.toString(arr)
  5. Use CharArray.contentToString() instead of Arrays.toString(arr)
  6. Use FloatArray.contentToString() instead of Arrays.toString(arr)
  7. Use DoubleArray.contentToString() instead of Arrays.toString(arr)
  8. Use BooleanArray.contentToString() instead of Arrays.toString(arr)
  9. Use Array.contentToString() instead of Arrays.toString(arr)
  10. Use IntArray.contentEquals() instead of Arrays.equals(a, b)
  11. Use LongArray.contentEquals() instead of Arrays.equals(a, b)
  12. Use ByteArray.contentEquals() instead of Arrays.equals(a, b)
  13. Use ShortArray.contentEquals() instead of Arrays.equals(a, b)
  14. Use CharArray.contentEquals() instead of Arrays.equals(a, b)
  15. Use FloatArray.contentEquals() instead of Arrays.equals(a, b)
  16. Use DoubleArray.contentEquals() instead of Arrays.equals(a, b)
  17. Use BooleanArray.contentEquals() instead of Arrays.equals(a, b)
  18. Use Array.contentEquals() instead of Arrays.equals(a, b)
  19. Use IntArray.contentHashCode() instead of Arrays.hashCode(arr)
  20. Use LongArray.contentHashCode() instead of Arrays.hashCode(arr)
  21. Use ByteArray.contentHashCode() instead of Arrays.hashCode(arr)
  22. Use ShortArray.contentHashCode() instead of Arrays.hashCode(arr)
  23. Use CharArray.contentHashCode() instead of Arrays.hashCode(arr)
  24. Use FloatArray.contentHashCode() instead of Arrays.hashCode(arr)
  25. Use DoubleArray.contentHashCode() instead of Arrays.hashCode(arr)
  26. Use BooleanArray.contentHashCode() instead of Arrays.hashCode(arr)
  27. Use Array.contentHashCode() instead of Arrays.hashCode(arr)
  28. Use Array.contentDeepToString() instead of Arrays.deepToString(arr)
  29. Use Array.contentDeepEquals() instead of Arrays.deepEquals(a, b)
  30. Use Array.contentDeepHashCode() instead of Arrays.deepHashCode(arr)
  31. Use IntArray.fill() instead of Arrays.fill(arr, value)
  32. Use LongArray.fill() instead of Arrays.fill(arr, value)
  33. Use ByteArray.fill() instead of Arrays.fill(arr, value)
  34. Use ShortArray.fill() instead of Arrays.fill(arr, value)
  35. Use CharArray.fill() instead of Arrays.fill(arr, value)
  36. Use FloatArray.fill() instead of Arrays.fill(arr, value)
  37. Use DoubleArray.fill() instead of Arrays.fill(arr, value)
  38. Use BooleanArray.fill() instead of Arrays.fill(arr, value)
  39. Use IntArray.sort() instead of Arrays.sort(arr)
  40. Use LongArray.sort() instead of Arrays.sort(arr)
  41. Use ByteArray.sort() instead of Arrays.sort(arr)
  42. Use ShortArray.sort() instead of Arrays.sort(arr)
  43. Use CharArray.sort() instead of Arrays.sort(arr)
  44. Use FloatArray.sort() instead of Arrays.sort(arr)
  45. Use DoubleArray.sort() instead of Arrays.sort(arr)
  46. Use IntArray.binarySearch() instead of Arrays.binarySearch(arr, key)
  47. Use LongArray.binarySearch() instead of Arrays.binarySearch(arr, key)
  48. Use ByteArray.binarySearch() instead of Arrays.binarySearch(arr, key)
  49. Use ShortArray.binarySearch() instead of Arrays.binarySearch(arr, key)
  50. Use CharArray.binarySearch() instead of Arrays.binarySearch(arr, key)
  51. Use FloatArray.binarySearch() instead of Arrays.binarySearch(arr, key)
  52. Use DoubleArray.binarySearch() instead of Arrays.binarySearch(arr, key)
  53. Use IntArray.copyOf() instead of Arrays.copyOf(arr, newLength)
  54. Use LongArray.copyOf() instead of Arrays.copyOf(arr, newLength)
  55. Use ByteArray.copyOf() instead of Arrays.copyOf(arr, newLength)
  56. Use ShortArray.copyOf() instead of Arrays.copyOf(arr, newLength)
  57. Use CharArray.copyOf() instead of Arrays.copyOf(arr, newLength)
  58. Use FloatArray.copyOf() instead of Arrays.copyOf(arr, newLength)
  59. Use DoubleArray.copyOf() instead of Arrays.copyOf(arr, newLength)
  60. Use BooleanArray.copyOf() instead of Arrays.copyOf(arr, newLength)
  61. Use CharArray.concatToString() instead of String(charArray)
  62. Use ByteArray.decodeToString() instead of String(byteArray)