[F] Fix warnings

pull/88/head
Azalea 2024-11-21 12:26:36 -05:00
parent a947a81772
commit 0e176d5608
4 changed files with 5 additions and 5 deletions

View File

@ -113,7 +113,6 @@ springBoot {
hibernate {
enhancement {
enableLazyInitialization = true
enableDirtyTracking = false
enableAssociationManagement = false
enableExtendedEnhancement = false
}

View File

@ -57,7 +57,7 @@ annotation class SettingField(
fun <T : Any> KClass<T>.vars() = memberProperties.mapNotNull { it as? Var<T, Any> }
fun <T : Any> KClass<T>.varsMap() = vars().associateBy { it.name }
fun <T : Any> KClass<T>.getters() = java.methods.filter { it.name.startsWith("get") }
fun <T : Any> KClass<T>.gettersMap() = getters().associateBy { it.name.removePrefix("get").decapitalize() }
fun <T : Any> KClass<T>.gettersMap() = getters().associateBy { it.name.removePrefix("get").firstCharLower() }
infix fun KCallable<*>.returns(type: KClass<*>) = returnType.jvmErasure.isSubclassOf(type)
@Suppress("UNCHECKED_CAST")
fun <C, T: Any> Var<C, T>.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<String, Any>.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

View File

@ -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 <reified T> ObjectMapper.parse(str: Str) = readValue(str, T::class.java)
inline fun <reified T> ObjectMapper.parse(map: Map<*, *>) = convertValue(map, T::class.java)

View File

@ -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)