@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2026 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Base64NoPaddingCodec.kt
|
||||
* LastUpdate 2026-11-16 14:24:59
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.base
|
||||
|
||||
import java.util.*
|
||||
|
||||
internal class Base64NoPaddingCodec : BaseCodec {
|
||||
|
||||
/*
|
||||
* Base64编码器实例
|
||||
* 用于执行字节数组到Base64字符串的编码操作
|
||||
*/
|
||||
val encoder: Base64.Encoder = Base64.getUrlEncoder().withoutPadding()
|
||||
|
||||
/*
|
||||
* Base64解码器实例
|
||||
* 用于执行Base64字符串到字节数组的解码操作
|
||||
*/
|
||||
val decoder: Base64.Decoder = Base64.getUrlDecoder()
|
||||
|
||||
/*
|
||||
* 将字节数组编码为Base64字符串
|
||||
*
|
||||
* @param bytes 待编码的字节数组
|
||||
* @return 编码后的Base64字符串
|
||||
*/
|
||||
override fun encode(bytes: ByteArray): String {
|
||||
return encoder.encodeToString(bytes)
|
||||
}
|
||||
|
||||
/*
|
||||
* 将Base64字符串解码为字节数组
|
||||
*
|
||||
* @param string 待解码的Base64字符串
|
||||
* @return 解码后的字节数组
|
||||
*/
|
||||
override fun decode(string: String): ByteArray {
|
||||
return decoder.decode(string)
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Base64UrlCodec.kt
|
||||
* LastUpdate 2026-03-12 10:34:36
|
||||
* LastUpdate 2026-11-16 14:24:59
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
|
||||
@@ -16,23 +16,36 @@
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile BaseType.kt
|
||||
* LastUpdate 2026-03-12 10:08:42
|
||||
* LastUpdate 2026-11-16 14:21:51
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.base
|
||||
|
||||
enum class BaseType(val baseCodec: BaseCodec) : BaseCodec {
|
||||
import com.mingliqiye.utils.base.code.BASE10 as CODE_BASE10
|
||||
import com.mingliqiye.utils.base.code.BASE16 as CODE_BASE16
|
||||
import com.mingliqiye.utils.base.code.BASE2 as CODE_BASE2
|
||||
import com.mingliqiye.utils.base.code.BASE256 as CODE_BASE256
|
||||
import com.mingliqiye.utils.base.code.BASE64 as CODE_BASE64
|
||||
import com.mingliqiye.utils.base.code.BASE64_NO_PADDING as CODE_BASE64_NO_PADDING
|
||||
import com.mingliqiye.utils.base.code.BASE64_URL as CODE_BASE64_URL
|
||||
import com.mingliqiye.utils.base.code.BASE91 as CODE_BASE91
|
||||
|
||||
BASE2(com.mingliqiye.utils.base.code.BASE2),
|
||||
BASE10(com.mingliqiye.utils.base.code.BASE10),
|
||||
BASE16(com.mingliqiye.utils.base.code.BASE16),
|
||||
BASE64(com.mingliqiye.utils.base.code.BASE64),
|
||||
BASE64URL(com.mingliqiye.utils.base.code.BASE64URL),
|
||||
BASE91(com.mingliqiye.utils.base.code.BASE91),
|
||||
BASE256(com.mingliqiye.utils.base.code.BASE256);
|
||||
enum class BaseType(private val baseCodec: () -> BaseCodec) : BaseCodec {
|
||||
|
||||
override fun encode(bytes: ByteArray) = baseCodec.encode(bytes)
|
||||
override fun decode(string: String) = baseCodec.decode(string)
|
||||
BASE2(::CODE_BASE2),
|
||||
BASE10(::CODE_BASE10),
|
||||
BASE16(::CODE_BASE16),
|
||||
BASE64(::CODE_BASE64),
|
||||
BASE64_URL(::CODE_BASE64_URL),
|
||||
BASE64_NO_PADDING(::CODE_BASE64_NO_PADDING),
|
||||
BASE91(::CODE_BASE91),
|
||||
BASE256(::CODE_BASE256);
|
||||
|
||||
val codec
|
||||
get() = baseCodec()
|
||||
|
||||
override fun encode(bytes: ByteArray) = codec.encode(bytes)
|
||||
override fun decode(string: String) = codec.decode(string)
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile BaseCodes.kt
|
||||
* LastUpdate 2026-03-12 10:03:32
|
||||
* LastUpdate 2026-11-16 14:10:57
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
@@ -63,10 +63,16 @@ val BASE64: BaseCodec by lazy {
|
||||
}
|
||||
|
||||
@get:JvmName("base64Url")
|
||||
val BASE64URL: BaseCodec by lazy {
|
||||
val BASE64_URL: BaseCodec by lazy {
|
||||
Base64UrlCodec()
|
||||
}
|
||||
|
||||
@get:JvmName("base64NoPadding")
|
||||
val BASE64_NO_PADDING: BaseCodec by lazy {
|
||||
Base64NoPaddingCodec()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提供Base91编码器的懒加载实例。
|
||||
* 该编码器用于将数据编码为Base91格式,具有较高的压缩效率。
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile ByteFlags.kt
|
||||
* LastUpdate 2026-06-21 10:40:58
|
||||
* LastUpdate 2026-11-16 21:35:04
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
@@ -64,7 +64,7 @@ data class ByteFlags(
|
||||
*
|
||||
* @param byte 要解析的字节
|
||||
*/
|
||||
fun fromByte(byte: Byte) {
|
||||
fun fromByte(byte: Byte): ByteFlags {
|
||||
val value = byte.toInt() and 0xFF
|
||||
b0 = (value and 0x01) != 0
|
||||
b1 = (value and 0x02) != 0
|
||||
@@ -74,6 +74,7 @@ data class ByteFlags(
|
||||
b5 = (value and 0x20) != 0
|
||||
b6 = (value and 0x40) != 0
|
||||
b7 = (value and 0x80) != 0
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +123,7 @@ data class ByteFlags(
|
||||
* @param value 要设置的布尔值
|
||||
* @throws IndexOutOfBoundsException 如果索引不在 0~7 范围内
|
||||
*/
|
||||
operator fun set(index: Int, value: Boolean) {
|
||||
operator fun set(index: Int, value: Boolean): ByteFlags {
|
||||
when (index) {
|
||||
0 -> b0 = value
|
||||
1 -> b1 = value
|
||||
@@ -134,12 +135,13 @@ data class ByteFlags(
|
||||
7 -> b7 = value
|
||||
else -> throw IndexOutOfBoundsException("索引必须在0-7之间")
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* 将所有 8 个位设置为 `true`。
|
||||
*/
|
||||
fun setAll() {
|
||||
fun setAll(): ByteFlags {
|
||||
b0 = true
|
||||
b1 = true
|
||||
b2 = true
|
||||
@@ -148,12 +150,14 @@ data class ByteFlags(
|
||||
b5 = true
|
||||
b6 = true
|
||||
b7 = true
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* 将所有 8 个位设置为 `false`。
|
||||
*/
|
||||
fun clearAll() {
|
||||
fun clearAll(): ByteFlags {
|
||||
b0 = false
|
||||
b1 = false
|
||||
b2 = false
|
||||
@@ -162,12 +166,14 @@ data class ByteFlags(
|
||||
b5 = false
|
||||
b6 = false
|
||||
b7 = false
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* 对所有位执行逻辑取反(true ↔ false)。
|
||||
*/
|
||||
fun toggleAll() {
|
||||
fun toggleAll(): ByteFlags {
|
||||
b0 = !b0
|
||||
b1 = !b1
|
||||
b2 = !b2
|
||||
@@ -176,6 +182,8 @@ data class ByteFlags(
|
||||
b5 = !b5
|
||||
b6 = !b6
|
||||
b7 = !b7
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,8 +192,9 @@ data class ByteFlags(
|
||||
* @param index 要切换的位索引(0~7)
|
||||
* @throws IndexOutOfBoundsException 如果索引无效
|
||||
*/
|
||||
fun toggle(index: Int) {
|
||||
fun toggle(index: Int): ByteFlags {
|
||||
this[index] = !this[index]
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -304,7 +313,7 @@ data class ByteFlags(
|
||||
* @param array 布尔数组(长度至少为 8)
|
||||
* @throws IllegalArgumentException 如果数组长度不足 8
|
||||
*/
|
||||
fun fromBooleanArray(array: BooleanArray) {
|
||||
fun fromBooleanArray(array: BooleanArray): ByteFlags {
|
||||
require(array.size >= 8) { "数组长度至少为8" }
|
||||
b0 = array[0]
|
||||
b1 = array[1]
|
||||
@@ -314,6 +323,7 @@ data class ByteFlags(
|
||||
b5 = array[5]
|
||||
b6 = array[6]
|
||||
b7 = array[7]
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -434,7 +444,6 @@ data class ByteFlags(
|
||||
fun fromBinaryString(binary: String): ByteFlags {
|
||||
require(binary.length == 8) { "二进制字符串长度必须为8" }
|
||||
require(binary.all { it == '0' || it == '1' }) { "二进制字符串只能包含0和1" }
|
||||
|
||||
return ByteFlags(
|
||||
binary[7] == '1', // b0 是最低位(对应字符串最后一位)
|
||||
binary[6] == '1',
|
||||
@@ -447,6 +456,10 @@ data class ByteFlags(
|
||||
)
|
||||
}
|
||||
|
||||
fun fromBooleanArray(booleanArray: BooleanArray): ByteFlags {
|
||||
return ByteFlags().fromBooleanArray(booleanArray)
|
||||
}
|
||||
|
||||
/**
|
||||
* 从整数创建 [ByteFlags] 实例(仅使用低 8 位)。
|
||||
*
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile MingLiLogger.kt
|
||||
* LastUpdate 2026-02-06 08:27:44
|
||||
* LastUpdate 2026-11-16 11:35:40
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
@@ -24,6 +24,7 @@ package com.mingliqiye.utils.logger
|
||||
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.Marker
|
||||
import org.slf4j.helpers.MessageFormatter
|
||||
|
||||
class MingLiLogger(private val name: String) : Logger {
|
||||
override fun getName(): String {
|
||||
@@ -40,14 +41,14 @@ class MingLiLogger(private val name: String) : Logger {
|
||||
|
||||
override fun trace(format: String?, arg: Any?) {
|
||||
format?.let {
|
||||
val message = format1(it, arg)
|
||||
val message = format(it, arg)
|
||||
toPrintln(message, MingLiLoggerLevel.TRACE)
|
||||
}
|
||||
}
|
||||
|
||||
override fun trace(format: String?, arg1: Any?, arg2: Any?) {
|
||||
format?.let {
|
||||
val message = format2(it, arg1, arg2)
|
||||
val message = format(it, arg1, arg2)
|
||||
toPrintln(message, MingLiLoggerLevel.TRACE)
|
||||
}
|
||||
}
|
||||
@@ -100,14 +101,14 @@ class MingLiLogger(private val name: String) : Logger {
|
||||
|
||||
override fun debug(format: String?, arg: Any?) {
|
||||
format?.let {
|
||||
val message = format1(it, arg)
|
||||
val message = format(it, arg)
|
||||
toPrintln(message, MingLiLoggerLevel.DEBUG)
|
||||
}
|
||||
}
|
||||
|
||||
override fun debug(format: String?, arg1: Any?, arg2: Any?) {
|
||||
format?.let {
|
||||
val message = format2(it, arg1, arg2)
|
||||
val message = format(it, arg1, arg2)
|
||||
toPrintln(message, MingLiLoggerLevel.DEBUG)
|
||||
}
|
||||
}
|
||||
@@ -160,14 +161,14 @@ class MingLiLogger(private val name: String) : Logger {
|
||||
|
||||
override fun info(format: String?, arg: Any?) {
|
||||
format?.let {
|
||||
val message = format1(it, arg)
|
||||
val message = format(it, arg)
|
||||
toPrintln(message, MingLiLoggerLevel.INFO)
|
||||
}
|
||||
}
|
||||
|
||||
override fun info(format: String?, arg1: Any?, arg2: Any?) {
|
||||
format?.let {
|
||||
val message = format2(it, arg1, arg2)
|
||||
val message = format(it, arg1, arg2)
|
||||
toPrintln(message, MingLiLoggerLevel.INFO)
|
||||
}
|
||||
}
|
||||
@@ -220,7 +221,7 @@ class MingLiLogger(private val name: String) : Logger {
|
||||
|
||||
override fun warn(format: String?, arg: Any?) {
|
||||
format?.let {
|
||||
val message = format1(it, arg)
|
||||
val message = format(it, arg)
|
||||
toPrintln(message, MingLiLoggerLevel.WARN)
|
||||
}
|
||||
}
|
||||
@@ -234,7 +235,7 @@ class MingLiLogger(private val name: String) : Logger {
|
||||
|
||||
override fun warn(format: String?, arg1: Any?, arg2: Any?) {
|
||||
format?.let {
|
||||
val message = format2(it, arg1, arg2)
|
||||
val message = format(it, arg1, arg2)
|
||||
toPrintln(message, MingLiLoggerLevel.WARN)
|
||||
}
|
||||
}
|
||||
@@ -280,14 +281,14 @@ class MingLiLogger(private val name: String) : Logger {
|
||||
|
||||
override fun error(format: String?, arg: Any?) {
|
||||
format?.let {
|
||||
val message = format1(it, arg)
|
||||
val message = format(it, arg)
|
||||
toPrintln(message, MingLiLoggerLevel.ERROR)
|
||||
}
|
||||
}
|
||||
|
||||
override fun error(format: String?, arg1: Any?, arg2: Any?) {
|
||||
format?.let {
|
||||
val message = format2(it, arg1, arg2)
|
||||
val message = format(it, arg1, arg2)
|
||||
toPrintln(message, MingLiLoggerLevel.ERROR)
|
||||
}
|
||||
}
|
||||
@@ -343,24 +344,14 @@ class MingLiLogger(private val name: String) : Logger {
|
||||
System.out.write(string.toByteArray())
|
||||
}
|
||||
|
||||
private fun format1(format: String, arg: Any?): String {
|
||||
return if (format.contains("{}")) {
|
||||
format.replaceFirst("{}", arg?.toString() ?: "null")
|
||||
} else {
|
||||
"$format $arg"
|
||||
}
|
||||
}
|
||||
|
||||
private fun format2(format: String, arg1: Any?, arg2: Any?): String {
|
||||
return format.replaceFirst("{}", arg1?.toString() ?: "null")
|
||||
.replaceFirst("{}", arg2?.toString() ?: "null")
|
||||
private fun format(format: String, vararg args: Any?): String {
|
||||
return formatArray(format, args)
|
||||
}
|
||||
|
||||
private fun formatArray(format: String, arguments: Array<out Any?>): String {
|
||||
var result = format
|
||||
for (arg in arguments) {
|
||||
result = result.replaceFirst("{}", arg?.toString() ?: "null")
|
||||
}
|
||||
return result
|
||||
return MessageFormatter.arrayFormat(
|
||||
format,
|
||||
arguments
|
||||
).message
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -16,7 +16,7 @@
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile JSONAAutoConfiguration.kt
|
||||
* LastUpdate 2026-11-09 14:59:49
|
||||
* LastUpdate 2026-11-16 11:28:52
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
@@ -41,9 +41,7 @@ open class JSONAAutoConfiguration(
|
||||
init {
|
||||
JSONA.setJsonApi(jsonApi)
|
||||
log.info(
|
||||
"JSONA use ${
|
||||
jsonApi.javaClass
|
||||
}"
|
||||
"JSONA use {}", jsonApi.javaClass
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -16,7 +16,7 @@
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Jackson3AutoConfiguration.kt
|
||||
* LastUpdate 2026-11-09 14:18:45
|
||||
* LastUpdate 2026-11-17 10:16:38
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
@@ -39,8 +39,8 @@ open class Jackson3AutoConfiguration {
|
||||
|
||||
private val log = MingLiLoggerFactory.getLogger<Jackson3AutoConfiguration>()
|
||||
|
||||
@Bean("UUIDJsonConverterJsonMapperCustomizer")
|
||||
@ConditionalOnMissingBean(name = ["UUIDJsonConverterJsonMapperCustomizer"])
|
||||
@Bean("jackson3MapperBuilderCustomizer")
|
||||
@ConditionalOnMissingBean(name = ["jackson3MapperBuilderCustomizer"])
|
||||
fun jsonMapperBuilderCustomizer(builders: ObjectProvider<JacksonBuilder>): JsonMapperBuilderCustomizer {
|
||||
val builderList = builders.orderedStream().toList()
|
||||
var jacksonJsonBuilderImpl = JacksonJsonBuilderImpl()
|
||||
@@ -52,7 +52,7 @@ open class Jackson3AutoConfiguration {
|
||||
it.addModules(
|
||||
*jacksonJsonBuilderImpl.getData().map { converter ->
|
||||
converter.getJackson3Module().also { module ->
|
||||
log.info("Jackson3 Module Install ${module.moduleName}")
|
||||
log.debug("Jackson3 Module Install {}", module.moduleName)
|
||||
}
|
||||
}.toTypedArray()
|
||||
)
|
||||
|
||||
+5
-3
@@ -16,7 +16,7 @@
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile JacksonJsonAutoConfiguration.kt
|
||||
* LastUpdate 2026-11-09 14:19:05
|
||||
* LastUpdate 2026-11-16 23:32:09
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.mingliqiye.utils.springboot.autoconfigure.builder.JacksonJsonBuilderI
|
||||
import org.springframework.beans.factory.ObjectProvider
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer
|
||||
import org.springframework.context.annotation.Bean
|
||||
|
||||
@@ -67,7 +68,8 @@ open class JacksonJsonAutoConfiguration {
|
||||
private val log = MingLiLoggerFactory.getLogger<JacksonJsonAutoConfiguration>()
|
||||
}
|
||||
|
||||
@Bean("mingliUtilsJacksonObjectMapperBuilderCustomizer")
|
||||
@Bean("jacksonMapperBuilderCustomizer")
|
||||
@ConditionalOnMissingBean(name = ["jacksonMapperBuilderCustomizer"])
|
||||
fun jackson2ObjectMapperBuilderCustomizer(builders: ObjectProvider<JacksonBuilder>): Jackson2ObjectMapperBuilderCustomizer {
|
||||
val builderList = builders.orderedStream().toList()
|
||||
var jacksonJsonBuilderImpl = JacksonJsonBuilderImpl()
|
||||
@@ -78,7 +80,7 @@ open class JacksonJsonAutoConfiguration {
|
||||
builder.modulesToInstall(
|
||||
*jacksonJsonBuilderImpl.getData().map { converter ->
|
||||
converter.getJacksonModule().also { module ->
|
||||
log.info("Jackson Module Install ${module.moduleName}")
|
||||
log.debug("Jackson Module Install {}", module.moduleName)
|
||||
}
|
||||
}.toTypedArray()
|
||||
)
|
||||
|
||||
+3
-3
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName FastBaseMapper.kt
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Okhttp3AutoConfiguration.kt
|
||||
* LastUpdate 2026-10-26 23:22:18
|
||||
* LastUpdate 2026-11-16 11:29:35
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
@@ -98,7 +98,7 @@ open class Okhttp3AutoConfiguration {
|
||||
b.build()
|
||||
}.also {
|
||||
okhttp = it
|
||||
log.info("load $connt OkhttpBuilder initialized OkHttpClient successfully")
|
||||
log.info("load {} OkhttpBuilder initialized OkHttpClient successfully", connt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-27
@@ -16,38 +16,12 @@
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile JacksonBuilder.kt
|
||||
* LastUpdate 2026-11-09 14:39:28
|
||||
* LastUpdate 2026-11-16 11:36:46
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.springboot.autoconfigure.builder
|
||||
|
||||
import com.mingliqiye.utils.json.converters.base.JsonConverter
|
||||
|
||||
sealed class JacksonJsonBuilder {
|
||||
abstract fun addJsonConverter(jsonConverter: JsonConverter<*, *>): JacksonJsonBuilder
|
||||
abstract fun addJsonConverters(vararg jsonConverters: JsonConverter<*, *>): JacksonJsonBuilder
|
||||
}
|
||||
|
||||
open class JacksonJsonBuilderImpl : JacksonJsonBuilder() {
|
||||
override fun addJsonConverter(jsonConverter: JsonConverter<*, *>): JacksonJsonBuilderImpl {
|
||||
data.add(jsonConverter)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun addJsonConverters(vararg jsonConverters: JsonConverter<*, *>): JacksonJsonBuilder {
|
||||
data.addAll(jsonConverters)
|
||||
return this
|
||||
}
|
||||
|
||||
private val data = mutableListOf<JsonConverter<*, *>>()
|
||||
|
||||
fun getData(): List<JsonConverter<*, *>> {
|
||||
return data.toList()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
fun interface JacksonBuilder {
|
||||
fun customize(builder: JacksonJsonBuilder): JacksonJsonBuilder
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2026 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile JacksonJsonBuilder.kt
|
||||
* LastUpdate 2026-11-16 11:36:46
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.springboot.autoconfigure.builder
|
||||
|
||||
import com.mingliqiye.utils.json.converters.base.JsonConverter
|
||||
|
||||
sealed class JacksonJsonBuilder {
|
||||
abstract fun addJsonConverter(jsonConverter: JsonConverter<*, *>): JacksonJsonBuilder
|
||||
abstract fun addJsonConverters(vararg jsonConverters: JsonConverter<*, *>): JacksonJsonBuilder
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2026 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile JacksonJsonBuilderImpl.kt
|
||||
* LastUpdate 2026-11-16 11:36:46
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.springboot.autoconfigure.builder
|
||||
|
||||
import com.mingliqiye.utils.json.converters.base.JsonConverter
|
||||
|
||||
open class JacksonJsonBuilderImpl : JacksonJsonBuilder() {
|
||||
override fun addJsonConverter(jsonConverter: JsonConverter<*, *>): JacksonJsonBuilderImpl {
|
||||
data.add(jsonConverter)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun addJsonConverters(vararg jsonConverters: JsonConverter<*, *>): JacksonJsonBuilder {
|
||||
data.addAll(jsonConverters)
|
||||
return this
|
||||
}
|
||||
|
||||
private val data = mutableListOf<JsonConverter<*, *>>()
|
||||
|
||||
fun getData(): List<JsonConverter<*, *>> {
|
||||
return data.toList()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile DateTime.kt
|
||||
* LastUpdate 2026-03-14 16:12:08
|
||||
* LastUpdate 2026-11-17 10:16:38
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
@@ -543,4 +543,9 @@ class DateTime private constructor(
|
||||
(it.epochSecond * 1000L) + (it.nano / 1_000_000L)
|
||||
}
|
||||
}
|
||||
|
||||
val epochSecond: Long
|
||||
get() {
|
||||
return toInstant().epochSecond
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile UUID.kt
|
||||
* LastUpdate 2026-06-21 10:40:58
|
||||
* LastUpdate 2026-11-16 14:29:35
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
@@ -422,7 +422,7 @@ class UUID : Serializable {
|
||||
}
|
||||
|
||||
fun of(str: String, base: BaseType): UUID {
|
||||
return UUID(base.baseCodec.decode(str))
|
||||
return UUID(base.codec.decode(str))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -552,7 +552,7 @@ class UUID : Serializable {
|
||||
}
|
||||
|
||||
fun getString(baseType: BaseType): String {
|
||||
return getString(baseType.baseCodec)
|
||||
return getString(baseType.codec)
|
||||
}
|
||||
|
||||
fun getString(baseCodec: BaseCodec): String {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2026 mingliqiye
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
~ ProjectName mingli-utils
|
||||
~ ModuleName mingli-utils.test
|
||||
~ CurrentFile log4j2.xml
|
||||
~ LastUpdate 2026-11-16 12:59:01
|
||||
~ UpdateUser MingLiPro
|
||||
-->
|
||||
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="CONSOLE" target="SYSTEM_OUT">
|
||||
<PatternLayout
|
||||
pattern="%style{%d{yyyy-MM-dd HH:mm:ss.SSSSSSS}}{bright,magenta} %highlight{[%p]}{FATAL=white, ERROR=bright_red, WARN=bright_yellow, INFO=bright_green, DEBUG=bright_cyan, TRACE=bright_blue} [%style{%t}{bright,yellow}/%style{%c{1}}{bright,cyan}] -> %style{%m}{#EEDFCC}%n"/>
|
||||
</Console>
|
||||
<RollingFile name="FILE"
|
||||
fileName="log/current.log"
|
||||
filePattern="log/%d{yyyy/MM/dd}.log">
|
||||
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSSSSSS} %p %t/%c/%C.%M(%F:%L) --> %m%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
</RollingFile>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="DEBUG">
|
||||
<AppenderRef ref="CONSOLE"/>
|
||||
<AppenderRef ref="FILE"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
Reference in New Issue
Block a user