From 1954f408e7c0a8289695adf27e89fe64e62335cf Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 8 May 2021 19:02:06 +0100 Subject: [PATCH] Replace deprecated capitalize() function Signed-off-by: Graham --- buffer-generator/build.gradle.kts | 1 + .../main/kotlin/org/openrs2/buffer/generator/IntType.kt | 1 + .../openrs2/deob/bytecode/remap/FieldMappingGenerator.kt | 1 + util/src/main/kotlin/org/openrs2/util/StringUtils.kt | 4 ++++ util/src/test/kotlin/org/openrs2/util/StringUtilsTest.kt | 7 +++++++ 5 files changed, 14 insertions(+) diff --git a/buffer-generator/build.gradle.kts b/buffer-generator/build.gradle.kts index 1bf96e3a..47becb2b 100644 --- a/buffer-generator/build.gradle.kts +++ b/buffer-generator/build.gradle.kts @@ -11,6 +11,7 @@ application { dependencies { api(libs.clikt) + implementation(projects.util) implementation(libs.kotlinPoet) implementation(libs.netty.buffer) } diff --git a/buffer-generator/src/main/kotlin/org/openrs2/buffer/generator/IntType.kt b/buffer-generator/src/main/kotlin/org/openrs2/buffer/generator/IntType.kt index 8d98ea2c..c2dcbbd3 100644 --- a/buffer-generator/src/main/kotlin/org/openrs2/buffer/generator/IntType.kt +++ b/buffer-generator/src/main/kotlin/org/openrs2/buffer/generator/IntType.kt @@ -1,5 +1,6 @@ package org.openrs2.buffer.generator +import org.openrs2.util.capitalize import kotlin.reflect.KClass public enum class IntType( diff --git a/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/remap/FieldMappingGenerator.kt b/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/remap/FieldMappingGenerator.kt index a33fa955..fbf56dcf 100644 --- a/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/remap/FieldMappingGenerator.kt +++ b/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/remap/FieldMappingGenerator.kt @@ -5,6 +5,7 @@ import org.openrs2.asm.MemberRef import org.openrs2.asm.classpath.ClassPath import org.openrs2.asm.filter.MemberFilter import org.openrs2.deob.util.map.NameMap +import org.openrs2.util.capitalize import org.openrs2.util.collect.DisjointSet import org.openrs2.util.indefiniteArticle diff --git a/util/src/main/kotlin/org/openrs2/util/StringUtils.kt b/util/src/main/kotlin/org/openrs2/util/StringUtils.kt index 8ce100bd..42ae8c86 100644 --- a/util/src/main/kotlin/org/openrs2/util/StringUtils.kt +++ b/util/src/main/kotlin/org/openrs2/util/StringUtils.kt @@ -18,3 +18,7 @@ public fun CharSequence.krHashCode(): Int { } return hash } + +public fun String.capitalize(): String { + return replaceFirstChar { it.titlecase() } +} diff --git a/util/src/test/kotlin/org/openrs2/util/StringUtilsTest.kt b/util/src/test/kotlin/org/openrs2/util/StringUtilsTest.kt index c633a118..11c7abde 100644 --- a/util/src/test/kotlin/org/openrs2/util/StringUtilsTest.kt +++ b/util/src/test/kotlin/org/openrs2/util/StringUtilsTest.kt @@ -20,4 +20,11 @@ class StringUtilsTest { assertEquals(99162322, "hello".krHashCode()) assertEquals(92340183, "h€llo".krHashCode()) } + + @Test + fun testCapitalize() { + assertEquals("Hello", "hello".capitalize()) + assertEquals("Hello", "Hello".capitalize()) + assertEquals("HELLO", "HELLO".capitalize()) + } }