From 0e176d560846cf16f7504f0d954bfe15f4f04acc Mon Sep 17 00:00:00 2001 From: Azalea <22280294+hykilpikonna@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:26:36 -0500 Subject: [PATCH] [F] Fix warnings --- build.gradle.kts | 1 - src/main/java/ext/Ext.kt | 3 ++- src/main/java/ext/Json.kt | 2 +- src/main/java/icu/samnyan/aqua/net/components/GeoIP.kt | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 79dae0c9..172db05d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -113,7 +113,6 @@ springBoot { hibernate { enhancement { enableLazyInitialization = true - enableDirtyTracking = false enableAssociationManagement = false enableExtendedEnhancement = false } diff --git a/src/main/java/ext/Ext.kt b/src/main/java/ext/Ext.kt index 3f008bc5..0d713f18 100644 --- a/src/main/java/ext/Ext.kt +++ b/src/main/java/ext/Ext.kt @@ -57,7 +57,7 @@ annotation class SettingField( fun KClass.vars() = memberProperties.mapNotNull { it as? Var } fun KClass.varsMap() = vars().associateBy { it.name } fun KClass.getters() = java.methods.filter { it.name.startsWith("get") } -fun KClass.gettersMap() = getters().associateBy { it.name.removePrefix("get").decapitalize() } +fun KClass.gettersMap() = getters().associateBy { it.name.removePrefix("get").firstCharLower() } infix fun KCallable<*>.returns(type: KClass<*>) = returnType.jvmErasure.isSubclassOf(type) @Suppress("UNCHECKED_CAST") fun Var.setCast(obj: C, value: String) = set(obj, when (returnType.classifier) { @@ -130,6 +130,7 @@ val Date.sec get() = time / 1000 // Encodings fun Long.toHex(len: Int = 16): Str = "0x${this.toString(len).padStart(len, '0').uppercase()}" fun Map.toUrl() = entries.joinToString("&") { (k, v) -> "$k=$v" } +fun String.firstCharLower() = replaceFirstChar { it.lowercase() } fun Any.long() = when (this) { is Boolean -> if (this) 1L else 0 diff --git a/src/main/java/ext/Json.kt b/src/main/java/ext/Json.kt index c93ccc80..964b3b38 100644 --- a/src/main/java/ext/Json.kt +++ b/src/main/java/ext/Json.kt @@ -30,7 +30,7 @@ val JACKSON = jacksonObjectMapper().apply { registerModule(JSON_FUZZY_BOOLEAN) registerModule(JSON_DATETIME) configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) - setPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CAMEL_CASE); + propertyNamingStrategy = PropertyNamingStrategies.LOWER_CAMEL_CASE; } inline fun ObjectMapper.parse(str: Str) = readValue(str, T::class.java) inline fun ObjectMapper.parse(map: Map<*, *>) = convertValue(map, T::class.java) diff --git a/src/main/java/icu/samnyan/aqua/net/components/GeoIP.kt b/src/main/java/icu/samnyan/aqua/net/components/GeoIP.kt index b1913e9c..c926b14a 100644 --- a/src/main/java/icu/samnyan/aqua/net/components/GeoIP.kt +++ b/src/main/java/icu/samnyan/aqua/net/components/GeoIP.kt @@ -11,7 +11,7 @@ import org.springframework.context.annotation.Configuration import org.springframework.stereotype.Service import java.io.File import java.net.InetAddress -import java.net.URL +import java.net.URI import java.nio.file.Files @@ -38,7 +38,7 @@ class GeoIP( // Download from GitHub try { log.info("Downloading GeoLite2 database to ${props.geoLitePath}") - URL("https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-Country.mmdb").openStream() + URI("https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-Country.mmdb").toURL().openStream() .use { Files.copy(it, File(props.geoLitePath).toPath()) } } catch (e: Exception) { log.error("Failed to download GeoLite2 database", e)