Compare commits

...
2 Commits
Author SHA1 Message Date
minglipro 16da482de7 v5.4.4
Gitea Actions Build / Build (push) Canceled after 0s
2026-11-17 10:25:13 +08:00
minglipro aa83f575b1 v5.4.4
Gitea Actions Build / Build (push) Canceled after 0s
2026-11-17 10:16:43 +08:00
19 changed files with 463 additions and 257 deletions
+185 -160
View File
@@ -16,24 +16,49 @@
* ProjectName mingli-utils
* ModuleName mingli-utils
* CurrentFile build.gradle.kts
* LastUpdate 2026-10-28 21:50:32
* LastUpdate 2026-11-17 10:19:02
* UpdateUser MingLiPro
*/
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import kotlin.math.sign
/*
* 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
* CurrentFile build.gradle.kts
* LastUpdate 2026-11-17 10:18:28
* UpdateUser MingLiPro
*/
plugins {
idea
java
signing
`java-library`
`maven-publish`
kotlin("jvm") version "2.2.20"
kotlin("kapt") version "2.2.20"
id("org.jetbrains.dokka") version "2.1.0"
id("org.jetbrains.dokka-javadoc") version "2.1.0"
kotlin("plugin.spring") version "2.1.0"
idea
java
signing
`java-library`
`maven-publish`
kotlin("jvm") version "2.2.20"
kotlin("kapt") version "2.2.20"
id("org.jetbrains.dokka") version "2.1.0"
id("org.jetbrains.dokka-javadoc") version "2.1.0"
kotlin("plugin.spring") version "2.1.0"
}
val GROUPSID = project.properties["GROUPSID"] as String
val VERSIONS = project.properties["VERSIONS"] as String
@@ -45,205 +70,205 @@ group = GROUPSID
version = VERSIONS
base {
archivesName.set(ARTIFACTID)
archivesName.set(ARTIFACTID)
}
val buildDir: java.nio.file.Path = File("build").toPath()
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(JDKVERSIONS))
withSourcesJar()
toolchain.languageVersion.set(JavaLanguageVersion.of(JDKVERSIONS))
withSourcesJar()
}
kotlin {
jvmToolchain(JDKVERSIONS)
jvmToolchain(JDKVERSIONS)
}
repositories {
mavenLocal()
maven {
url = uri("https://maven.mingliqiye.com/")
}
mavenCentral()
mavenLocal()
maven {
name = "mingliqiye-public"
url = uri("https://repository.mingliqiye.com/repository/maven-public/")
}
mavenCentral()
}
dependencies {
implementation("org.slf4j:slf4j-api:2.0.17")
implementation(kotlin("reflect"))
api("com.mingliqiye.utils.aliasfor:alias-for:1.0.1")
compileOnly("org.mindrot:jbcrypt:0.4")
compileOnly("com.squareup.okhttp3:okhttp:5.3.2")
compileOnly("com.fasterxml.jackson.core:jackson-databind:2.21.0")
compileOnly("com.fasterxml.jackson.module:jackson-module-kotlin:2.21.0")
compileOnly("org.springframework:spring-context:5.3.0")
compileOnly("org.springframework.boot:spring-boot-autoconfigure:2.7.16")
compileOnly("tools.jackson.core:jackson-databind:3.1.0")
compileOnly(fileTree("libs"))
compileOnly("com.google.code.gson:gson:2.13.2")
compileOnly("org.mybatis:mybatis:3.5.19")
compileOnly("io.netty:netty-all:4.2.15.Final")
compileOnly("com.baomidou:mybatis-plus-core:3.5.15")
compileOnly("net.java.dev.jna:jna:5.17.0")
compileOnly("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.8")
compileOnly("com.baomidou:mybatis-plus-extension:3.5.15")
compileOnly("com.baomidou:mybatis-plus-jsqlparser:3.5.15")
compileOnly("com.baomidou:mybatis-plus-spring:3.5.9")
testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("com.mingliqiye.logger:logger-log4j2:1.0.9")
testImplementation("com.google.code.gson:gson:2.13.2")
implementation("org.slf4j:slf4j-api:2.0.17")
implementation(kotlin("reflect"))
api("com.mingliqiye.utils.aliasfor:alias-for:1.0.1")
compileOnly("org.mindrot:jbcrypt:0.4")
compileOnly("com.squareup.okhttp3:okhttp:5.3.2")
compileOnly("com.fasterxml.jackson.core:jackson-databind:2.21.0")
compileOnly("com.fasterxml.jackson.module:jackson-module-kotlin:2.21.0")
compileOnly("org.springframework:spring-context:5.3.0")
compileOnly("org.springframework.boot:spring-boot-autoconfigure:2.7.16")
compileOnly("tools.jackson.core:jackson-databind:3.1.0")
compileOnly(fileTree("libs"))
compileOnly("com.google.code.gson:gson:2.13.2")
compileOnly("org.mybatis:mybatis:3.5.19")
compileOnly("io.netty:netty-all:4.2.15.Final")
compileOnly("com.baomidou:mybatis-plus-core:3.5.15")
compileOnly("net.java.dev.jna:jna:5.17.0")
compileOnly("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.8")
compileOnly("com.baomidou:mybatis-plus-extension:3.5.15")
compileOnly("com.baomidou:mybatis-plus-jsqlparser:3.5.15")
compileOnly("com.baomidou:mybatis-plus-spring:3.5.9")
testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("com.mingliqiye.logger:logger-log4j2:1.0.9")
testImplementation("com.google.code.gson:gson:2.13.2")
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.21.0")
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.21.0")
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.21.0")
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.21.0")
testImplementation("tools.jackson.module:jackson-module-kotlin:3.1.0")
testImplementation("tools.jackson.core:jackson-databind:3.1.0")
testImplementation(kotlin("test"))
testImplementation("tools.jackson.module:jackson-module-kotlin:3.1.0")
testImplementation("tools.jackson.core:jackson-databind:3.1.0")
testImplementation(kotlin("test"))
}
repositories {
mavenLocal()
mavenLocal()
}
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.encoding = "UTF-8"
}
tasks.named<Test>("test") {
useJUnitPlatform()
useJUnitPlatform()
}
tasks.withType<JavaExec> {
jvmArgs(
"-Dfile.encoding=UTF-8", "-Dsun.stdout.encoding=UTF-8", "-Dsun.stderr.encoding=UTF-8"
)
jvmArgs(
"-Dfile.encoding=UTF-8", "-Dsun.stdout.encoding=UTF-8", "-Dsun.stderr.encoding=UTF-8"
)
}
kapt {
arguments {
arg(
"kapt.kotlin.generated",
project.layout.buildDirectory.dir("generated/source/kapt/main").get().asFile.absolutePath
)
}
arguments {
arg(
"kapt.kotlin.generated",
project.layout.buildDirectory.dir("generated/source/kapt/main").get().asFile.absolutePath
)
}
}
tasks.withType<org.gradle.jvm.tasks.Jar> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from("LICENSE") { into("META-INF") }
from("NOTICE") { into("META-INF") }
manifest {
attributes(
mapOf(
"Main-Class" to "com.mingliqiye.utils.main.Main",
"Specification-Title" to ARTIFACTID,
"Specification-Version" to VERSIONS,
"Specification-Vendor" to "minglipro",
"Specification-Build-Time" to LocalDateTime.now()
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSS")),
"Specification-Package" to GROUPSID,
"Specification-Build-Number" to "1",
"Specification-Build-OS" to System.getProperty("os.name"),
"Specification-Build-Java" to System.getProperty("java.version"),
"Specification-Build-Java-Vendor" to System.getProperty("java.vendor"),
"Specification-Build-Java-Vendor-URL" to System.getProperty("java.vendor.url"),
"Implementation-Title" to ARTIFACTID,
"Implementation-Version" to VERSIONS,
"Implementation-Package" to GROUPSID,
"Implementation-Vendor" to "minglipro",
"Implementation-Build-Time" to LocalDateTime.now()
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSS"))
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from("LICENSE") { into("META-INF") }
from("NOTICE") { into("META-INF") }
manifest {
attributes(
mapOf(
"Main-Class" to "com.mingliqiye.utils.main.Main",
"Specification-Title" to ARTIFACTID,
"Specification-Version" to VERSIONS,
"Specification-Vendor" to "minglipro",
"Specification-Build-Time" to LocalDateTime.now()
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSS")),
"Specification-Package" to GROUPSID,
"Specification-Build-Number" to "1",
"Specification-Build-OS" to System.getProperty("os.name"),
"Specification-Build-Java" to System.getProperty("java.version"),
"Specification-Build-Java-Vendor" to System.getProperty("java.vendor"),
"Specification-Build-Java-Vendor-URL" to System.getProperty("java.vendor.url"),
"Implementation-Title" to ARTIFACTID,
"Implementation-Version" to VERSIONS,
"Implementation-Package" to GROUPSID,
"Implementation-Vendor" to "minglipro",
"Implementation-Build-Time" to LocalDateTime.now()
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSS"))
)
)
}
)
)
}
}
val isJdk8Build = project.findProperty("buildForJdk8") == "true"
tasks.register<Jar>("javaDocJar") {
group = "build"
archiveClassifier.set("javadoc-dec")
dependsOn("dokkaGeneratePublicationJavadoc")
from(buildDir.resolve("dokka/javadoc"))
dokka {
pluginsConfiguration.html {
customAssets.from("logo.png")
}
}
tasks.register<Jar>("javaDocJar") {
group = "build"
archiveClassifier.set("javadoc")
dependsOn("dokkaGenerateJavadoc")
from(buildDir.resolve("dokka/javadoc"))
}
tasks.register<Jar>("kotlinDocJar") {
group = "build"
archiveClassifier.set("javadoc")
dependsOn("dokkaGeneratePublicationHtml")
from(buildDir.resolve("dokka/html"))
group = "build"
archiveClassifier.set("kotlindoc")
dependsOn("dokkaGeneratePublicationHtml")
from(buildDir.resolve("dokka/html"))
}
publishing {
repositories {
maven {
name = "mingliqiye"
url = uri("https://repository.mingliqiye.com/repository/maven")
credentials {
username = System.getenv("mingliqiye.username")
password = System.getenv("mingliqiye.password")
}
}
}
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
artifact(tasks.named("kotlinDocJar"))
artifactId = ARTIFACTID
pom {
name = "mingli-utils"
url = "https://mingli-utils.mingliqiye.com"
description = "A Java/kotlin Utils"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "minglipro"
name = "mingli"
email = "minglipro@163.com"
}
}
scm {
connection = "scm:git:https://git.mingliqiye.com/minglipro/mingli-utils.git"
developerConnection = "scm:git:https://git.mingliqiye.com:minglipro/mingli-utils.git"
url = "https://git.mingliqiye.com/minglipro/mingli-utils"
}
}
}
}
signing {
sign(publishing.publications)
}
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
artifact(tasks.named("javaDocJar"))
artifact(tasks.named("kotlinDocJar"))
artifactId = ARTIFACTID
pom {
name = "mingli-utils"
url = "https://mingli-utils.mingliqiye.com"
description = "A Java/kotlin Utils"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "minglipro"
name = "mingli"
email = "minglipro@163.com"
}
}
scm {
connection = "scm:git:https://git.mingliqiye.com/minglipro/mingli-utils.git"
developerConnection = "scm:git:https://git.mingliqiye.com:minglipro/mingli-utils.git"
url = "https://git.mingliqiye.com/minglipro/mingli-utils"
}
}
}
}
signing {
sign(publishing.publications)
}
}
tasks.build {
dependsOn("javaDocJar", "kotlinDocJar")
dependsOn("javaDocJar", "kotlinDocJar")
}
tasks.processResources {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
outputs.upToDateWhen { false }
filesMatching(listOf("META-INF/meta-data", "fabric.mod.json")) {
expand(
project.properties + mapOf(
"buildTime" to LocalDateTime.now().format(
DateTimeFormatter.ofPattern(
"yyyy-MM-dd HH:mm:ss.SSSSSSS"
)
)
)
)
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
outputs.upToDateWhen { false }
filesMatching(listOf("META-INF/meta-data", "fabric.mod.json")) {
expand(
project.properties + mapOf(
"buildTime" to LocalDateTime.now().format(
DateTimeFormatter.ofPattern(
"yyyy-MM-dd HH:mm:ss.SSSSSSS"
)
)
)
)
}
}
signing {
val secretKeyRingFile = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
val keyId = System.getenv("SIGNING_KEY_ID")
useGpgCmd()
project.ext.set("signing.secretKeyRingFile", secretKeyRingFile)
project.ext.set("signing.keyId", keyId)
project.ext.set("signing.password", "")
val secretKeyRingFile = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
val keyId = System.getenv("SIGNING_KEY_ID")
useGpgCmd()
project.ext.set("signing.secretKeyRingFile", secretKeyRingFile)
project.ext.set("signing.keyId", keyId)
project.ext.set("signing.password", "")
}
+2 -2
View File
@@ -16,10 +16,10 @@
# ProjectName mingli-utils
# ModuleName mingli-utils
# CurrentFile gradle.properties
# LastUpdate 2026-11-09 19:49:52
# LastUpdate 2026-11-17 09:07:20
# UpdateUser MingLiPro
#
JDKVERSIONS=17
GROUPSID=com.mingliqiye.utils
ARTIFACTID=mingli-utils
VERSIONS=5.4.3
VERSIONS=5.4.4
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

@@ -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
}
}
@@ -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
)
}
}
@@ -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()
)
@@ -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()
)
@@ -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)
}
}
@@ -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
@@ -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
}
@@ -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 {
+45
View File
@@ -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>