diff --git a/build.gradle.kts b/build.gradle.kts index af47839..30d148f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,7 @@ * ProjectName mingli-utils * ModuleName mingli-utils * CurrentFile build.gradle.kts - * LastUpdate 2026-01-06 14:05:20 + * LastUpdate 2026-01-08 11:10:03 * UpdateUser MingLiPro */ @@ -76,7 +76,7 @@ dependencies { compileOnly("com.google.code.gson:gson:2.13.1") compileOnly("org.mybatis:mybatis:3.5.19") compileOnly("com.alibaba.fastjson2:fastjson2:2.0.58") - compileOnly("io.netty:netty-all:4.2.9.Final") + compileOnly("io.netty:netty-all:4.1.130.Final") compileOnly("com.baomidou:mybatis-plus-core:3.0.1") compileOnly("net.java.dev.jna:jna:5.17.0") diff --git a/gradle.properties b/gradle.properties index 02d97e6..d9d8d7d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,13 +16,13 @@ # ProjectName mingli-utils # ModuleName mingli-utils # CurrentFile gradle.properties -# LastUpdate 2026-01-07 10:02:36 +# LastUpdate 2026-01-08 13:20:25 # UpdateUser MingLiPro # JDKVERSIONS=1.8 GROUPSID=com.mingliqiye.utils ARTIFACTID=mingli-utils -VERSIONS=4.2.7 +VERSIONS=4.3.2 signing.keyId=B22AA93B signing.password= signing.secretKeyRingFile=secret.gpg diff --git a/src/main/java/com/mingliqiye/utils/mybatis/QuickBaseTypeHandlerValueGetter.java b/src/main/java/com/mingliqiye/utils/mybatis/QuickBaseTypeHandlerValueGetter.java deleted file mode 100644 index 099b5d3..0000000 --- a/src/main/java/com/mingliqiye/utils/mybatis/QuickBaseTypeHandlerValueGetter.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2025 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 QuickBaseTypeHandlerValueGetter.java - * LastUpdate 2025-09-21 21:07:10 - * UpdateUser MingLiPro - */ - -package com.mingliqiye.utils.mybatis; - -import java.sql.CallableStatement; -import java.sql.ResultSet; - -/** - * QuickBaseTypeHandlerValueGetter类用于封装CallableStatement和ResultSet对象的获取操作 - * 该类提供了对存储过程调用结果和查询结果集的统一访问接口 - */ -public class QuickBaseTypeHandlerValueGetter { - private final CallableStatement callableStatement; - private final ResultSet resultSet; - - /** - * 构造函数,初始化QuickBaseTypeHandlerValueGetter实例 - * - * @param callableStatement 存储过程调用语句对象,用于执行存储过程 - * @param resultSet 查询结果集对象,用于获取查询结果 - */ - public QuickBaseTypeHandlerValueGetter(CallableStatement callableStatement, ResultSet resultSet) { - this.callableStatement = callableStatement; - this.resultSet = resultSet; - } - - /** - * 获取结果集对象 - * - * @return ResultSet 查询结果集对象 - */ - public ResultSet getResultSet() { - return resultSet; - } - - /** - * 获取存储过程调用语句对象 - * - * @return CallableStatement 存储过程调用语句对象 - */ - public CallableStatement getCallableStatement() { - return callableStatement; - } -} diff --git a/src/main/java/com/mingliqiye/utils/mybatis/CallType.java b/src/main/kotlin/com/mingliqiye/utils/mybatis/CallType.kt similarity index 78% rename from src/main/java/com/mingliqiye/utils/mybatis/CallType.java rename to src/main/kotlin/com/mingliqiye/utils/mybatis/CallType.kt index 2d5a6da..91894f4 100644 --- a/src/main/java/com/mingliqiye/utils/mybatis/CallType.java +++ b/src/main/kotlin/com/mingliqiye/utils/mybatis/CallType.kt @@ -1,5 +1,5 @@ /* - * Copyright 2025 mingliqiye + * 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. @@ -15,18 +15,14 @@ * * ProjectName mingli-utils * ModuleName mingli-utils.main - * CurrentFile CallType.java - * LastUpdate 2025-09-21 21:06:52 + * CurrentFile CallType.kt + * LastUpdate 2026-01-07 19:06:59 * UpdateUser MingLiPro */ -package com.mingliqiye.utils.mybatis; +package com.mingliqiye.utils.mybatis -/** - * CallType枚举类定义了不同的调用类型 - * 用于标识数据库操作中结果集和可调用语句的访问方式 - */ -public enum CallType { +enum class CallType { /** * 通过索引访问结果集 * 使用数字索引位置来获取结果集中的数据 diff --git a/src/main/java/com/mingliqiye/utils/mybatis/QuickBaseTypeHandler.java b/src/main/kotlin/com/mingliqiye/utils/mybatis/QuickBaseTypeHandler.kt similarity index 66% rename from src/main/java/com/mingliqiye/utils/mybatis/QuickBaseTypeHandler.java rename to src/main/kotlin/com/mingliqiye/utils/mybatis/QuickBaseTypeHandler.kt index a2da2d1..90d30bf 100644 --- a/src/main/java/com/mingliqiye/utils/mybatis/QuickBaseTypeHandler.java +++ b/src/main/kotlin/com/mingliqiye/utils/mybatis/QuickBaseTypeHandler.kt @@ -1,5 +1,5 @@ /* - * Copyright 2025 mingliqiye + * 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. @@ -15,30 +15,28 @@ * * ProjectName mingli-utils * ModuleName mingli-utils.main - * CurrentFile QuickBaseTypeHandler.java - * LastUpdate 2025-09-21 21:10:36 + * CurrentFile QuickBaseTypeHandler.kt + * LastUpdate 2026-01-08 07:59:47 * UpdateUser MingLiPro */ -package com.mingliqiye.utils.mybatis; +package com.mingliqiye.utils.mybatis -import org.apache.ibatis.type.BaseTypeHandler; -import org.apache.ibatis.type.JdbcType; - -import java.sql.CallableStatement; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; +import org.apache.ibatis.type.BaseTypeHandler +import org.apache.ibatis.type.JdbcType +import java.sql.CallableStatement +import java.sql.PreparedStatement +import java.sql.ResultSet +import java.sql.SQLException /** * 抽象类 QuickBaseTypeHandler 是 MyBatis 的 BaseTypeHandler 的扩展, * 提供了统一处理数据库字段与 Java 类型之间转换的抽象方法。 * 子类需要实现 getValue 和 setValue 方法来完成具体的类型转换逻辑。 * - * @param 要处理的 Java 类型 + * @param T 要处理的 Java 类型 */ -public abstract class QuickBaseTypeHandler extends BaseTypeHandler { - +abstract class QuickBaseTypeHandler : BaseTypeHandler() { /** * 抽象方法,用于从数据库结果中获取并转换为 Java 类型 T。 * @@ -49,12 +47,13 @@ public abstract class QuickBaseTypeHandler extends BaseTypeHandler { * @return 转换后的 Java 类型 T 实例 * @throws SQLException SQL 执行异常时抛出 */ - public abstract T getValue( - QuickBaseTypeHandlerValueGetter vg, - CallType ct, - Integer ci, - String cn - ) throws SQLException; + @Throws(SQLException::class) + abstract fun getValue( + vg: QuickBaseTypeHandlerValueGetter, + ct: CallType, + ci: Int?, + cn: String? + ): T /** * 抽象方法,用于将 Java 类型 T 设置到 PreparedStatement 中。 @@ -65,7 +64,8 @@ public abstract class QuickBaseTypeHandler extends BaseTypeHandler { * @param jdbcType JDBC 类型 * @throws SQLException SQL 执行异常时抛出 */ - public abstract void setValue(PreparedStatement ps, int index, T parameter, JdbcType jdbcType) throws SQLException; + @Throws(SQLException::class) + abstract fun setValue(ps: PreparedStatement, index: Int, parameter: T, jdbcType: JdbcType?) /** * 实现 BaseTypeHandler 的 setNonNullParameter 方法, @@ -77,9 +77,9 @@ public abstract class QuickBaseTypeHandler extends BaseTypeHandler { * @param jdbcType JDBC 类型 * @throws SQLException SQL 执行异常时抛出 */ - @Override - public void setNonNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException { - setValue(ps, i, parameter, jdbcType); + @Throws(SQLException::class) + override fun setNonNullParameter(ps: PreparedStatement, i: Int, parameter: T, jdbcType: JdbcType?) { + setValue(ps, i, parameter, jdbcType) } /** @@ -91,9 +91,9 @@ public abstract class QuickBaseTypeHandler extends BaseTypeHandler { * @return 转换后的 Java 类型 T 实例(可能为 null) * @throws SQLException SQL 执行异常时抛出 */ - @Override - public T getNullableResult(ResultSet rs, String columnName) throws SQLException { - return getValue(new QuickBaseTypeHandlerValueGetter(null, rs), CallType.RESULTSET_NAME, null, columnName); + @Throws(SQLException::class) + override fun getNullableResult(rs: ResultSet, columnName: String): T { + return getValue(QuickBaseTypeHandlerValueGetter(null, rs), CallType.RESULTSET_NAME, null, columnName) } /** @@ -105,9 +105,9 @@ public abstract class QuickBaseTypeHandler extends BaseTypeHandler { * @return 转换后的 Java 类型 T 实例(可能为 null) * @throws SQLException SQL 执行异常时抛出 */ - @Override - public T getNullableResult(ResultSet rs, int columnIndex) throws SQLException { - return getValue(new QuickBaseTypeHandlerValueGetter(null, rs), CallType.RESULTSET_NAME, columnIndex, null); + @Throws(SQLException::class) + override fun getNullableResult(rs: ResultSet, columnIndex: Int): T { + return getValue(QuickBaseTypeHandlerValueGetter(null, rs), CallType.RESULTSET_INDEX, columnIndex, null) } /** @@ -119,8 +119,8 @@ public abstract class QuickBaseTypeHandler extends BaseTypeHandler { * @return 转换后的 Java 类型 T 实例(可能为 null) * @throws SQLException SQL 执行异常时抛出 */ - @Override - public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { - return getValue(new QuickBaseTypeHandlerValueGetter(cs, null), CallType.CALLABLE_STATEMENT_INDEX, columnIndex, null); + @Throws(SQLException::class) + override fun getNullableResult(cs: CallableStatement, columnIndex: Int): T { + return getValue(QuickBaseTypeHandlerValueGetter(cs, null), CallType.CALLABLE_STATEMENT_INDEX, columnIndex, null) } } diff --git a/src/main/kotlin/com/mingliqiye/utils/mybatis/QuickBaseTypeHandlerValueGetter.kt b/src/main/kotlin/com/mingliqiye/utils/mybatis/QuickBaseTypeHandlerValueGetter.kt new file mode 100644 index 0000000..8253f6b --- /dev/null +++ b/src/main/kotlin/com/mingliqiye/utils/mybatis/QuickBaseTypeHandlerValueGetter.kt @@ -0,0 +1,28 @@ +/* + * 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 QuickBaseTypeHandlerValueGetter.kt + * LastUpdate 2026-01-07 19:10:44 + * UpdateUser MingLiPro + */ + +package com.mingliqiye.utils.mybatis + +import java.sql.CallableStatement +import java.sql.ResultSet + +data class QuickBaseTypeHandlerValueGetter(var callableStatement: CallableStatement?, var resultSet: ResultSet?) diff --git a/src/main/kotlin/com/mingliqiye/utils/mybatis/typehandler/datetime/DateTimeTypeHandler.kt b/src/main/kotlin/com/mingliqiye/utils/mybatis/typehandler/datetime/DateTimeTypeHandler.kt new file mode 100644 index 0000000..523116b --- /dev/null +++ b/src/main/kotlin/com/mingliqiye/utils/mybatis/typehandler/datetime/DateTimeTypeHandler.kt @@ -0,0 +1,63 @@ +/* + * 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 DateTimeTypeHandler.kt + * LastUpdate 2026-01-07 19:23:12 + * UpdateUser MingLiPro + */ + +package com.mingliqiye.utils.mybatis.typehandler.datetime + +import com.mingliqiye.utils.mybatis.CallType +import com.mingliqiye.utils.mybatis.QuickBaseTypeHandler +import com.mingliqiye.utils.mybatis.QuickBaseTypeHandlerValueGetter +import com.mingliqiye.utils.time.DateTime +import org.apache.ibatis.type.JdbcType +import org.apache.ibatis.type.MappedTypes +import java.sql.PreparedStatement +import java.sql.Timestamp + +/** + * DateTime类型处理器,用于在数据库和Java对象之间转换DateTime类型 + */ +@MappedTypes(DateTime::class) +class DateTimeTypeHandler : QuickBaseTypeHandler() { + + override fun getValue( + vg: QuickBaseTypeHandlerValueGetter, + ct: CallType, + ci: Int?, + cn: String? + ): DateTime { + return DateTime.of( + (when (ct) { + CallType.RESULTSET_INDEX -> vg.resultSet!!.getTimestamp(ci!!) + CallType.RESULTSET_NAME -> vg.resultSet!!.getTimestamp(cn!!) + CallType.CALLABLE_STATEMENT_INDEX -> vg.callableStatement!!.getTimestamp(ci!!) + }) + ) + } + + override fun setValue( + ps: PreparedStatement, + index: Int, + parameter: DateTime, + jdbcType: JdbcType? + ) { + ps.setTimestamp(index, Timestamp.valueOf(parameter.toLocalDateTime())) + } +} diff --git a/src/main/kotlin/com/mingliqiye/utils/mybatis/typehandler/mysql/uuid/MysqlUUIDBinaryTypeHandler.kt b/src/main/kotlin/com/mingliqiye/utils/mybatis/typehandler/mysql/uuid/MysqlUUIDBinaryTypeHandler.kt new file mode 100644 index 0000000..14bc082 --- /dev/null +++ b/src/main/kotlin/com/mingliqiye/utils/mybatis/typehandler/mysql/uuid/MysqlUUIDBinaryTypeHandler.kt @@ -0,0 +1,78 @@ +/* + * 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 MysqlUUIDBinaryTypeHandler.kt + * LastUpdate 2026-01-07 19:30:31 + * UpdateUser MingLiPro + */ + +package com.mingliqiye.utils.mybatis.typehandler.mysql.uuid + +import com.mingliqiye.utils.mybatis.CallType +import com.mingliqiye.utils.mybatis.QuickBaseTypeHandler +import com.mingliqiye.utils.mybatis.QuickBaseTypeHandlerValueGetter +import com.mingliqiye.utils.uuid.UUID +import com.mingliqiye.utils.uuid.mysqlToUuid +import com.mingliqiye.utils.uuid.uuidToMysql +import org.apache.ibatis.type.JdbcType +import org.apache.ibatis.type.MappedTypes +import java.sql.PreparedStatement + +@MappedTypes(UUID::class) +class MysqlUUIDBinaryTypeHandler : QuickBaseTypeHandler() { + + companion object { + /** + * 将字节数组转换为UUID对象 + * + * @param byteArray 字节数组 + * @return UUID对象,如果字节数组为null则返回null + */ + private fun toUUID(byteArray: ByteArray?): UUID? { + return byteArray?.let { UUID.of(mysqlToUuid(it)) } + } + + /** + * 将UUID对象转换为字节数组 + * + * @param uuid UUID对象 + * @return 字节数组,如果UUID为null则返回null + */ + fun toByteArray(uuid: UUID?): ByteArray? { + return uuid?.let { uuidToMysql(it.toBytes()) } + } + } + + override fun getValue( + vg: QuickBaseTypeHandlerValueGetter, ct: CallType, ci: Int?, cn: String? + ): UUID { + return toUUID( + when (ct) { + CallType.RESULTSET_NAME -> vg.resultSet!!.getBytes(cn!!) + CallType.RESULTSET_INDEX -> vg.resultSet!!.getBytes(ci!!) + CallType.CALLABLE_STATEMENT_INDEX -> vg.resultSet!!.getBytes(ci!!) + } + )!! + } + + override fun setValue( + ps: PreparedStatement, index: Int, parameter: UUID, jdbcType: JdbcType? + ) { + ps.setBytes(index, toByteArray(parameter)) + } + +} diff --git a/src/main/kotlin/com/mingliqiye/utils/netty/ClientScheduleReconnect.kt b/src/main/kotlin/com/mingliqiye/utils/netty/ClientScheduleReconnect.kt new file mode 100644 index 0000000..ee305aa --- /dev/null +++ b/src/main/kotlin/com/mingliqiye/utils/netty/ClientScheduleReconnect.kt @@ -0,0 +1,105 @@ +/* + * 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 ClientScheduleReconnect.kt + * LastUpdate 2026-01-08 10:45:37 + * UpdateUser MingLiPro + */ + +package com.mingliqiye.utils.netty + +import io.netty.bootstrap.Bootstrap +import io.netty.channel.Channel +import io.netty.channel.ChannelFuture +import io.netty.channel.ChannelFutureListener +import java.util.concurrent.TimeUnit + +abstract class ClientScheduleReconnect( + protected val bootstrap: Bootstrap, + protected var delay: Long = 10L, + protected var timeUnit: TimeUnit = TimeUnit.SECONDS +) { + protected var isStop = false + protected var channel: Channel? = null + + + abstract fun onConnectedLog(channel: Channel) + abstract fun onConnectFailedLog(cause: Throwable?) + abstract fun onStoppedLog() + abstract fun doConnect(): ChannelFuture + + open fun updateReconnectDelay(newDelay: Long, newTimeUnit: TimeUnit) { + require(newDelay > 0) { "Delay must be positive" } + this.delay = newDelay + this.timeUnit = newTimeUnit + } + + open fun connect() { + doConnect().addListener(object : ChannelFutureListener { + override fun operationComplete(future: ChannelFuture) { + if (future.isSuccess) { + onConnected(future.channel()) + } else { + onConnectFailed(future.cause()) + } + } + }) + } + + + open fun stop() { + isStop = true + disConnect() + } + + open fun disConnect() { + channel?.close() + channel = null + } + + + open fun scheduleReconnect() { + if (isStop) { + onStoppedLog() + return + } + bootstrap.config().group().schedule({ + if (isStop) { + onStoppedLog() + return@schedule + } + connect() + }, delay, timeUnit) + } + + open fun onConnected(channel: Channel) { + this.channel = channel + onConnectedLog(channel) + channel.closeFuture().addListener { _ -> + scheduleReconnect() + } + } + + open fun onConnectFailed(cause: Throwable?) { + onConnectFailedLog(cause) + scheduleReconnect() + } + + open fun isConnected(): Boolean { + return channel?.isActive ?: false + } +} diff --git a/src/main/kotlin/com/mingliqiye/utils/netty/NamedThreadFactory.kt b/src/main/kotlin/com/mingliqiye/utils/netty/NamedThreadFactory.kt new file mode 100644 index 0000000..7e52a9a --- /dev/null +++ b/src/main/kotlin/com/mingliqiye/utils/netty/NamedThreadFactory.kt @@ -0,0 +1,73 @@ +/* + * 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 NamedThreadFactory.kt + * LastUpdate 2026-01-08 13:21:00 + * UpdateUser MingLiPro + */ + +package com.mingliqiye.utils.netty + +import io.netty.util.concurrent.FastThreadLocalThread +import java.util.concurrent.ThreadFactory +import java.util.concurrent.atomic.AtomicInteger + + +open class NamedThreadFactory(private val getName: NamedThreadFactoryNameGetter) : ThreadFactory { + + companion object { + + @JvmStatic + private val allThreadPoolNumber = AtomicInteger(0) + + @FunctionalInterface + fun interface NamedThreadFactoryNameGetter { + fun getName(clazz: Class, poolNumber: Int, threadNumber: Int): String + } + + @JvmStatic + val defaultGetName = + NamedThreadFactoryNameGetter { clazz, poolNumber, threadNumber -> "${clazz.simpleName}-$poolNumber-$threadNumber" } + + @JvmStatic + fun of(name: String): NamedThreadFactory { + return NamedThreadFactory { a, b, c -> + "$name-$c" + } + } + + @JvmStatic + fun of(getter: NamedThreadFactoryNameGetter = defaultGetName): NamedThreadFactory { + return NamedThreadFactory(getter) + } + } + + + private val threadNumber = AtomicInteger(0) + private val threadPoolNumber = allThreadPoolNumber.addAndGet(1) + + open fun getThreadName(clazz: Class, poolNumber: Int, threadNumber: Int) = + getName.getName(clazz, poolNumber, threadNumber) + + override fun newThread(r: Runnable): Thread { + return FastThreadLocalThread( + null, + r, + getThreadName(this.javaClass, threadPoolNumber, threadNumber.addAndGet(1)) + ) + } +} diff --git a/src/main/java/com/mingliqiye/utils/stream/StreamEmptyException.java b/src/main/kotlin/com/mingliqiye/utils/stream/StreamEmptyException.kt similarity index 62% rename from src/main/java/com/mingliqiye/utils/stream/StreamEmptyException.java rename to src/main/kotlin/com/mingliqiye/utils/stream/StreamEmptyException.kt index 14b8bcc..66e4955 100644 --- a/src/main/java/com/mingliqiye/utils/stream/StreamEmptyException.java +++ b/src/main/kotlin/com/mingliqiye/utils/stream/StreamEmptyException.kt @@ -1,5 +1,5 @@ /* - * Copyright 2025 mingliqiye + * 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. @@ -15,20 +15,15 @@ * * ProjectName mingli-utils * ModuleName mingli-utils.main - * CurrentFile StreamEmptyException.java - * LastUpdate 2025-09-20 13:24:07 + * CurrentFile StreamEmptyException.kt + * LastUpdate 2026-01-07 19:13:29 * UpdateUser MingLiPro */ -package com.mingliqiye.utils.stream; +package com.mingliqiye.utils.stream -public class StreamEmptyException extends java.lang.RuntimeException { +class StreamEmptyException : RuntimeException { + constructor(message: String) : super(message) - public StreamEmptyException(String message) { - super(message); - } - - public StreamEmptyException(String message, Throwable cause) { - super(message, cause); - } + constructor(message: String, cause: Throwable) : super(message, cause) } diff --git a/src/main/kotlin/com/mingliqiye/utils/uuid/MysqlUUIDv1.kt b/src/main/kotlin/com/mingliqiye/utils/uuid/MysqlUUIDv1.kt index c7bcd1a..a8319b1 100644 --- a/src/main/kotlin/com/mingliqiye/utils/uuid/MysqlUUIDv1.kt +++ b/src/main/kotlin/com/mingliqiye/utils/uuid/MysqlUUIDv1.kt @@ -1,5 +1,5 @@ /* - * Copyright 2025 mingliqiye + * 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. @@ -16,10 +16,10 @@ * ProjectName mingli-utils * ModuleName mingli-utils.main * CurrentFile MysqlUUIDv1.kt - * LastUpdate 2025-09-15 22:32:50 + * LastUpdate 2026-01-08 08:22:14 * UpdateUser MingLiPro */ -@file:JvmName("MysqlUUIDv1") +@file:JvmName("MysqlUUIDConvertor") package com.mingliqiye.utils.uuid diff --git a/src/main/kotlin/com/mingliqiye/utils/uuid/UUID.kt b/src/main/kotlin/com/mingliqiye/utils/uuid/UUID.kt index e4429ef..4d7fc71 100644 --- a/src/main/kotlin/com/mingliqiye/utils/uuid/UUID.kt +++ b/src/main/kotlin/com/mingliqiye/utils/uuid/UUID.kt @@ -16,7 +16,7 @@ * ProjectName mingli-utils * ModuleName mingli-utils.main * CurrentFile UUID.kt - * LastUpdate 2026-01-06 12:55:04 + * LastUpdate 2026-01-08 13:21:00 * UpdateUser MingLiPro */ @@ -537,7 +537,7 @@ class UUID : Serializable { * @return MySQL 格式的 UUID 字节数组 */ fun toMysql(): ByteArray { - return mysqlToUuid(this.data) + return uuidToMysql(this.data) } /** @@ -546,7 +546,7 @@ class UUID : Serializable { * @return MySQL 格式的 UUID 实例 */ fun toMysqlUUID(): UUID { - return of(mysqlToUuid(this.data)) + return of(uuidToMysql(this.data)) } /**