forked from Cookies_Github_mirror/AquaDX
[O] Redesign wacca score model
This commit is contained in:
@@ -117,6 +117,9 @@ catch (e: Exception) { null } }
|
||||
val Calendar.year get() = get(Calendar.YEAR)
|
||||
val Calendar.month get() = get(Calendar.MONTH) + 1
|
||||
val Calendar.day get() = get(Calendar.DAY_OF_MONTH)
|
||||
fun cal() = Calendar.getInstance()
|
||||
fun Date.cal() = Calendar.getInstance().apply { time = this@cal }
|
||||
operator fun Calendar.invoke(field: Int) = get(field)
|
||||
val Date.sec get() = time / 1000
|
||||
|
||||
// Encodings
|
||||
@@ -128,6 +131,8 @@ fun Any.long() = when (this) {
|
||||
is String -> toLong()
|
||||
else -> 400 - "Invalid number: $this"
|
||||
}
|
||||
fun Any.int() = long().toInt()
|
||||
operator fun Bool.unaryPlus() = if (this) 1 else 0
|
||||
|
||||
// Collections
|
||||
fun <T> ls(vararg args: T) = args.toList()
|
||||
@@ -163,4 +168,14 @@ fun Str.path() = Path.of(this)
|
||||
operator fun Path.div(part: Str) = resolve(part)
|
||||
fun Str.ensureEndingSlash() = if (endsWith('/')) this else "$this/"
|
||||
|
||||
fun <T: Any> T.logger() = LoggerFactory.getLogger(this::class.java)
|
||||
fun <T: Any> T.logger() = LoggerFactory.getLogger(this::class.java)
|
||||
|
||||
// I hate this ;-;
|
||||
operator fun <E> List<E>.component6(): E = get(5)
|
||||
operator fun <E> List<E>.component7(): E = get(6)
|
||||
operator fun <E> List<E>.component8(): E = get(7)
|
||||
operator fun <E> List<E>.component9(): E = get(8)
|
||||
operator fun <E> List<E>.component10(): E = get(9)
|
||||
operator fun <E> List<E>.component11(): E = get(10)
|
||||
operator fun <E> List<E>.component12(): E = get(11)
|
||||
operator fun <E> List<E>.component13(): E = get(12)
|
||||
|
||||
@@ -33,6 +33,7 @@ val JACKSON = jacksonObjectMapper().apply {
|
||||
setPropertyNamingStrategy(PropertyNamingStrategy.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)
|
||||
// TODO: https://stackoverflow.com/q/78197784/7346633
|
||||
inline fun <reified T> Str.parseJackson() = if (contains("null")) {
|
||||
val map = JACKSON.parse<MutableMap<String, Any>>(this)
|
||||
|
||||
Reference in New Issue
Block a user